The art and difficulty of naming in programming

Important note: (Do not read any of the comments in the thread without solving the challenge).

This article is a follow of my very first article
Every programmer should know these conventions and practices.

So in this article, I’ll develop a little …


This content originally appeared on DEV Community and was authored by DEV Community

Important note: (Do not read any of the comments in the thread without solving the challenge).

This article is a follow of my very first article
Every programmer should know these conventions and practices.

So in this article, I'll develop a little more in-depth the point: Give meaningful names.

Giving a meaningful name to our variables, functions, arguments, classes, attributes, and packages is both difficult and an art. Sometimes, and even often, every developer who cares about code quality stumbles upon naming issues. Personally, I can spend a lot of time just thinking about what will the best name for this, and I can choose one, change it later, multiple times until I find one or a colleague helps me to find the one that satisfied me the most, the one that makes me say or think, yeah, that is the perfect name.
Because, the name could drastically change how easily other developers and you (later, in a few years maybe ^_^) will quickly understand your code without necessary reading the details.

In this article, I'll just try to show you the impact of bad names and give more insights and concrete examples in a part2.

I want you to quickly determine without testing what the function does, and after that, find better names to replace the badly named variables in that function in order to make the function more readable and understandable. It's the function in the picture below, it's written in python.
You can start now, and read the rest of the article after you’re done. Are you ready to take the challenge?

So let's go:

Simple function poorly named in python

Congrats, no matter how much time you took to find it, 1min, or 1second, you agree with me that, after you’ve changed the variable's names with good ones, the function is more obvious to understand.
But you know, in reality, even the poorest developer can't write a code that is that much awful, at least, I hope so.

We are at the end of this short article. Feel free to add in the comments some real cases of naming issues you faced and which name you finally chose.


This content originally appeared on DEV Community and was authored by DEV Community


Print Share Comment Cite Upload Translate Updates
APA

DEV Community | Sciencx (2022-02-26T19:39:22+00:00) The art and difficulty of naming in programming. Retrieved from https://www.scien.cx/2022/02/26/the-art-and-difficulty-of-naming-in-programming/

MLA
" » The art and difficulty of naming in programming." DEV Community | Sciencx - Saturday February 26, 2022, https://www.scien.cx/2022/02/26/the-art-and-difficulty-of-naming-in-programming/
HARVARD
DEV Community | Sciencx Saturday February 26, 2022 » The art and difficulty of naming in programming., viewed ,<https://www.scien.cx/2022/02/26/the-art-and-difficulty-of-naming-in-programming/>
VANCOUVER
DEV Community | Sciencx - » The art and difficulty of naming in programming. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/26/the-art-and-difficulty-of-naming-in-programming/
CHICAGO
" » The art and difficulty of naming in programming." DEV Community | Sciencx - Accessed . https://www.scien.cx/2022/02/26/the-art-and-difficulty-of-naming-in-programming/
IEEE
" » The art and difficulty of naming in programming." DEV Community | Sciencx [Online]. Available: https://www.scien.cx/2022/02/26/the-art-and-difficulty-of-naming-in-programming/. [Accessed: ]
rf:citation
» The art and difficulty of naming in programming | DEV Community | Sciencx | https://www.scien.cx/2022/02/26/the-art-and-difficulty-of-naming-in-programming/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.