Eduardo Nunes
Clean Code: Meaningful Names
If you have to read the source code to understand the meaning of a variable name it is because that’s a bad name
Here is a list of best practices on namming variables, classes, functions / methods, interfaces and enums:
- Communicate your intent;
- Avoid disinformation;
- Pronounceable names;
- Avoid encodings (e.g. Hungarian notation);
- Classes, variables names should be nouns;
- Methods / functions should have verb names;
- Boolean methods should have names as predicates (e.g. isAuthenticated);
- Variables should have short names in small scopes and long names in large scopes;
- Functions should have long names in small scopes and short names in large scopes;
- Classes should have long names in private scopes and short names in public scopes;
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. (Martin Fowler, 2008)