3 ms·
It depends heavily on the type of code. C code with complex bit manipulations is different than C# or Java business code. But as a general rule I like to think
by jstimpfle 10y ago
It depends heavily on the type of code. C code with complex bit manipulations is different than C# or Java business code.
But as a general rule I like to think that if there are many variables whose purpose is so hard to remember that their names must be super descriptive, then the problem decomposition is probably lacking.
I also think that bad decomposition is often a consequence of OO style (where concerns tend to be intermingled rather than separated because objects tend to be trashcans for everything "related" to ill-defined concepts).
A good decomposition leads to source files with distinct concepts that lend themselves to short and memorable (but not overly descriptive) names within their limited scope.
Example: The following code has a very clearly defined scope and implements a data transformation with 5 distinct concepts (cols, rows, objs, spec, database). Incidentally these show up in just about every function of the file.
https://github.com/jstimpfle/python-wsl/blob/master/wsl/wslh/objects2rows.py https://github.com/jstimpfle/python-wsl/blob/master/wsl/wslh...
(I haven't bothered to document these concepts yet. Assuming documentation I'm convinced 4-letter variable names are just right, and repeating the documentation at every usage location is wrong).