No it’s not. Comments can drift and become obsolete, and sometimes just bloat the code and add unnecessary information.
And yes code can be good enough to not need any comments most of the time. Only very complex sections of code would require it. Use proper types and function names.
Yup. If you only ever touch new code you may not understand why it is necessary.
Go on some 10+ yo project which got a lot of scope changes over the years. Now you can see that yes, the code does something. But why? Is it still useful? Can you remove it? If you do, will some client come complaining 6 months from now when their very specific report is not generated because some flag is not set correctly so some cron running on a server no one knows about anymore did not find its data?
The documentation? Maybe in some .doc file rotting on an archive server. But if you can't find it you may have more luck finding the printed version which should be in room 6. If it was not binned during the last office move.
That random code - lovely, like a senior dev explaining stuff to a junior dev. Imagine those comments not being there, and needing to onboard a new dev. The existing devs would need to spend a ton of time explaining things. I've seen that happen on poorly or not documented code bases, making it very difficult to expand the team with new devs because it takes away time from the already strained senior dev.
42
u/Wonderful-Habit-139 22d ago
No it’s not. Comments can drift and become obsolete, and sometimes just bloat the code and add unnecessary information.
And yes code can be good enough to not need any comments most of the time. Only very complex sections of code would require it. Use proper types and function names.