This article is written as opinion. The opinions expressed within are solely those of the author, and do not represent the views of Red Hat.
Everything around us has a name, I mean everything, otherwise, how would we be able to refer to them, particularly in programming. From our project name, directories, variables, and more, a name must be associated with every item or else we lose their meaning and use.
So when you decide to work on a project, make sure you keep telling yourself that naming matters. There is more to a program than a compiler understanding what you’ve written and running the code. To create software, writing the code is one thing, maintaining the code is another. Sometimes, maintaining a code is more difficult than creating a new one. We are afraid we may bring the project down. So, below are some tips I gathered from the book “Clean Code” about how to use good namings when writing programs.
- Make sure you use names that show your intentions. Names should explain what they do, why they do what they do and how they do it.
- Endeavor to use names that carry single meaning. Do not use names that might carry very similar meaning to another thing.
- When there are differences between names, please make sure the distinction is clear.
- Ensure that names you use are easy to pronounce. Beyond communicating with the compiler, you want to be able to communicate with other developers about your project. So, use names that are easy to pronounce and reference.
- Use domain specific namings properly. Use names that easily map to the domain in which you are working on which also explains exactly how the naming works in that domain.
- Do not repeat namings. Ensure that not every variable you create is annotated with a certain prefix such that every name in your program has that name. This could lead to poor searching on your code.
- Endeavor to reach out more to the language you are using. Learn the vocabulary of the English language to help communicate more. The more words you know, the easier it is for you to communicate with other programmers.
Note: The tips given here are to guide you and are in no way rules written in stone. As more and more programmers become better aware of using good names, the world of programming would become easier not only to the current programmer but to other programmers that would join the field later.
Imagine a scenario where you look at a variable name and no idea comes to your mind about why it even exists. You look lost in a sea of code without any idea where to move. But the worse part is you wrote the code yourself and there is no one around to explain exactly what your intentions were when you created that variable or that class.
It’s never too late to start. Start small. Do not run off changing every piece of code you have ever written just yet. You might be overwhelmed. Take it one step at a time, Lean development matters.
Click here for an overview about Red Hat Development Suite a fully integrated development environment for modern enterprise development.
Join Red Hat Developers, a developer program for you to learn, share, and code faster – and get access to Red Hat software for your development. The developer program and software are both free!