Hacker News new | ask | show | jobs
by ruszki 1186 days ago
In my experience, people hate to read each other’s unnecessarily complex code. Nobody complained about a well written (ie easily understandable) codebase ever. This is why reviews exist among others. Comments are only useful if there is some magic because of performance reasons. In any other case, if comment seems to be necessary, then code should rather be refactored. It’s a code smell. Abstract classes, indirect loops in runtime call stack without IoC, and templates are also dangerous animals. Nobody complained so far for codebase where these were minimised, especially if microservice architecture was introduced which also inherently tames DRY on some level.
1 comments

> comments are code smell [paraphrasing]

Good news: there are kinds of extremely useful comments that do not repeat the code (your comments should not repeat the code). Comments are to express context/intent behind the code: the "why", the high level "what", and almost never the exact "how" (read code for that).

It looks like you only ever encountered the "how" comments. No amount of code refactoring would get you the "why" (context) comments.

GIT tells the why.
Yes, commit message is also a good place to provide the context for the commit.