2 ms·
You aren't writing comments for yourself today. You may not even be writing them for your colleagues today. You're writing the comments for someone looking at t
by js2 8y ago
You aren't writing comments for yourself today. You may not even be writing them for your colleagues today. You're writing the comments for someone looking at the code in the future, probably without whatever context is in your head now.
Also, the most important than you can document is the why because given enough time, a good enough programmer will be able to figure out the what, regardless of how complex it is. But if you made an unusual decision based on something going on in your head at the time, maybe based on some data or testing you had done, no one will know that unless you write it down. This goes part and parcel with a good commit message, which is another place to write down the why.
If you haven't had the experience at looking at your own code a year down the line and scratching your head at some piece of it, well you just haven't been coding long enough. Good comments and commit messages are like gold at those times.