There are only two hard problems in Computer Science: cache invalidation and naming things.
– Phil Karlton
We name and name and name. We name variables, functions, arguments, classes, source files, and the directories. Proper naming makes the code easier to read.
Intention-revealing names
The right name tells you why the variable, function or class exists. The name reveals what the piece of code does, and how it is used. If you need to explain the name in the comments, then the name does not reveal its intent well enough.
Disinformation
The code should not only mean what it does but also do what it says. For example, if you have a function cleanTheHouse() you’d expect it to clean the whole house and not only the kitchen or the bathroom.
Names are everywhere. Give them a meaning.
Leave a Reply