3 ms·
my priority for comments is that they should answer "why?" and "why not?" questions. Why does the method/function do it this way? Why didn't it choose that ot
by spinningslate 6y ago
my priority for comments is that they should answer "why?" and "why not?" questions. Why does the method/function do it this way? Why didn't it choose that other, perhaps more obvious route?
That's not necessary in every case. But it's true in a good number of them. The code alone can never tell you that - but it's often invaluable during evolution/refactoring.
- wiredfool 6y agoWhy does this code exist? What are you working around? What are the assumptions? What limitations? If it's complicated enough that I'm only understanding it because of the context of the last week, we need the comments. Anything that can speed the reverse engineering in 6 months when it breaks is helpful, because then you can quickly decide that we got different input or if we missed an edge case or whatever.
- Pokepokalypse 6y agoYah, and what's gross is when your team-mates criticize you for leaving comments at all. Let alone a lengthy discussion on why.