I recently watched the Clean Coders naming video and managed to take the following notes on variable/function/class namings,
- If you need comments, its not well named
- You shouldn't have to read the code to understand what a variable is for
- Don't use names that are misleading or present false information about the actual object.
- Names should be pronounceable, avoid using your own abbreviations
- Don’t prefix variables with their types, etc. i.e. float_speed, int_person_count, etc
Parts of Speech
- For classes/variables use noun names. For methods use verbs. For booleans make them predicates.
Regarding Scope & Naming
- Scope length & name length should be proportional. That is, the longer the scope of a variable, the longer the name.
- Classes/functions that have long scopes should have short concise names.
- Classes/functions that have short scopes should have long explanatory names.
The number one rule to remember about about code is it's read more than it is written. The worst situation to be in is when you have to read your own code and you can't tell what it does.