If a name is already used, we can always prefix it with 'the'.
TL;DR: don't prefix your variables.
-
Readability
-
Meaningless names
-
Use intention revealing names.
-
Avoid Indistinct noise words.
Refactoring 006 - Rename Result Variables
var result;
result = getSomeResult();
var theResult;
theResult = getSomeResult();
var averageSalary;
averageSalary = calculateAverageSalary();
var averageSalaryWithRaises;
averageSalaryWithRaises = calculateAverageSalary();
As with many of our naming conventions, we can instruct our linters to forbid names like theXxx....
- Readability
Always use intention revealing names.
If your names collide use local names, extract your methods and avoid 'the' prefixes.
Code Smell 38 - Abstract Names
Photo by Josue Michel on Unsplash
One difference between a smart programmer and a professional programmer is that the professional understands that clarity is king. Professionals use their powers for good and write code that others can understand.
Robert C. Martin
Software Engineering Great Quotes
This article is part of the CodeSmell Series.