What the reasonable alternative though? What's the happy medium?
What the reasonable alternative though? What's the happy medium?
...and this is the natural result of the 'no comments allowed in the code' nazi's that seem to permeate lots of organizations. For the life of me I could never understand that particular bandwagon.
I for one love it when I go back into my code after a few years and a few well placed comments remind me why I did what I did last time I worked on it.
Talk about a bone-headed outcome of claiming 'we don't allow comments in our code' mentality.
/* Using Duff's device see <reference> for speed and code size */
The poor developer assigned to replace it with "better code" had an impossible task because they couldn't find anything to replace it that wasn't either much slower or much bigger.
* Useless, like "locks the mutex" before a mutex.lock().
* Contrary to the code, like "This parameter contains the proc name without the instance" and then the parameter does contain the instance.
* Dubious, like it's not obvious what the comment means nor if what you are doing follows the comment or not.
Worst thing is when the code and the comment contradict and there's no good reason to trust one over the other in what the code should do (never go to sea with two chronometers).
I suppose it depends on the codebase you are working on. If it's your own code the likelihood of you agreeing with the comment increases, ofc.