HomeContact
Better Code Series Tip #2: Use MORE verbose naming.
Software Design
Better Code Series Tip #2: Use MORE verbose naming.
Kodi O'Neil
Kodi O'Neil
November 24, 2022
1 min

Table Of Contents

01
The Offense
02
Save Time Not Space

The Offense

Have you ever seen code that looks like this?

Screenshot_from_2022-11-23_21-43-10_ficyd4.png

What is “P”? What is the entity we are setting a zip code and a name for? If you scroll up further in the file that this code was taken from you would find that “P” stands for “Prison”.

As a user this would be obvious due to the header (not shown in the screenshot) above the form that displays “Update Prison”. As a developer, you could find out by scrolling up a little ways and ingesting the context that this form lives in.

But the question must be asked. Why did we condense the word prison?

Save Time Not Space

The problem with the above example is that we can’t tell right away what it is that P refers to. This is a relatively common occurrence among the “uninitiated” who believe saving some line space is worth the ambiguity.

It’s not.

When you use condensed variable, function, or class names you run the risk of erasing any discernible meaning from them. Remember, programming languages use English for a reason! Take advantage of this wonderful abstracted interface we are given to write instructions to our machines.

The more your code reads like proper English, the easier and faster it is to understand and work with.

better_naming_prison_e0q8tc.png

Ahh, that’s better. And look- we used proper JS camelCase too!


Tags

Kodi O'Neil

Kodi O'Neil

Software Developer

Expertise

Social Media

www

Related Posts

Better Code Series Tip #4: Abstract long conditionals!
Better Code Series Tip #4: Abstract long conditionals!
December 20, 2022
2 min

Quick Links

About UsContact Us

Social Media