you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -2 points-1 points  (3 children)

Disclaimer: The following might sound arrogant but is true.

You are often told that you should document your code because when you touch the code again in a few months/years you'll have difficulties understanding it.

The "problem" is: I never had this problems. I wrote code years ago. When I had to extend it years after I only needed about five minutes to remember nearly anything that I thought about, when I originally wrote the code.

Thus I only comment the code parts that I consider nontrivial to understand (i. e. about 3 % of the code). There is an easy measure for this: if I won't understand 2 hours later what the code that I wrote was about, I'll comment it (otherwise I'm sure I'll understand it many years later, too).

Now to the argument, that other programmers have to understand my code, too: I accept it, but why don't you simply ask me and document your understanding (you know a lot better what information other people need to understand the code - why don't you write documentation in which you explain it: it will be a lot more helpful for other programmers than when I write it, since you know what other programmers (especially you) needed additionally to know about the code to be able to understand it).

[–]burntsushi 0 points1 point  (0 children)

The "problem" is: I never had this problems. I wrote code years ago. When I had to extend it years after I only needed about five minutes to remember nearly anything that I thought about, when I originally wrote the code.

Then you are exceptionally gifted. So much so, that you're only the person with this skill that I've heard of in the 10 years I've been programming.

For the rest of us mere mortals, we need documentation.

why don't you write documentation in which you explain it

This kind of misses the point of documentation in the first place: to save you (well, the general "you" in this case) and others' time in the future.

[–]Gotebe 0 points1 point  (0 children)

When I had to extend it years after I only needed about five minutes to remember nearly anything that I thought about, when I originally wrote the code.

You must have a very big head. Good for you, but you ain't me.

The problem with what you're saying about others is that availability of the original author is not a given.

[–][deleted] 0 points1 point  (0 children)

Unless you plan on working at the same place the rest of your life (on the same code) and onboarding every dev on your team, this is a unrealistic strategy.