|
|
|
|
|
by BurningFrog
1832 days ago
|
|
My main solution is to use good function and variable names. Including - and I had some resistance to this - breaking out a variable or function solely to give something a name that needs describing. This way you have one source of truth. It can be wrong, but you only update it once, and it never conflicts with itself. I understand what you mean by "function and variable names are comments". We do use them to describe what the code does. Still, they are actually code :) |
|
// add vertical scroll bar
addHorizontalScrollBar(...)
I _know_ something is wrong.
Did the comment get out of synch with the code? Or the developer copied-and-pasted the wrong function? Or the function itself is misnamed? I don't know! Let's investigate... and fix whatever happens to be erroneous!
But when I see just
addHorizontalScrollBar(...)
all I know is that a horizontal bar seems to be added (provided the function name reflects its... er... function). I don't know whether it was intended behaviour. If it has not been, nothing indicates this at all.
I've actually caught real bugs this way, multiple times.