Comment only in extraordinary situations, when something you read can confuse someone. And by that I mean the business logic, not that you used a method that’s confusing to people since they only know the basics of the language.
Honestly, after a few years of working with juniors (and being one myself before that), I have to disagree with the last part. Sure, it’s fine for solo projects but people’s programming skills can vary heavily. I know people who will pull the wildest C++ compile time tricks you’ve ever seen, but a pointer to a pointer would somehow break their brain.
Comment smart, don’t comment every line like this
int i = 5; // Assigns the value 5 into the variable i.
Comment only in extraordinary situations, when something you read can confuse someone. And by that I mean the business logic, not that you used a method that’s confusing to people since they only know the basics of the language.
Honestly, after a few years of working with juniors (and being one myself before that), I have to disagree with the last part. Sure, it’s fine for solo projects but people’s programming skills can vary heavily. I know people who will pull the wildest C++ compile time tricks you’ve ever seen, but a pointer to a pointer would somehow break their brain.
I usually comment on whole groups of lines of code, so the goal of each part of the code is clear