Healthy Code On The Commode: Identifiernamingpostforworldwidewebblog
Healthy Code On The Commode: Identifiernamingpostforworldwidewebblog
It's easy to get carried away creating long identifiers. Longer names often make things more readable. But
names that are too long can decrease readability. There are many examples of variable names longer
than 60 characters on GitHub and elsewhere. In 58 characters, we managed this haiku for you to
consider:
Name variables
Using these simple guidelines
Beautiful source code
Names should be two things: clear (know what it refers to) and precise (know what it does not refer to).
Here are some guidelines to help:
• Omit words that are obvious given a variable's type declaration.
// Bad, the type tells us what these variables are:
String nameString; List<DateTime> holidayDateList;
// Better:
String name; List<DateTime> holidays;