Or, I guess a more appropriate question would be, do you?
People always ask, "do you comment your code?" I now ask, why do you comment? My manager was more or less flabbergasted when I stated, "I comment as needed only." I made the argument that if I'm having to comment the fundamentals of the language itself, then whoever is looking at the code shouldn't be touching it anyway. I also put forth the argument that in certain languages, comments can be extremely harmful. I can't tell you how many times I've found comments that were completely outdated, and didn't reflect the actual behavior of the code in question. This gives a false sense of security in comments. Also, I /constantly/ see comments in code that are almost exactly the same as the code itself! If a programmer has trouble understanding the basic fundamentals of the language, or programming itself, no comments are going to help him. Recently I was maintaining a project written recently that had calls to SleepEx() scattered throughout, each time with what seemed like a completely random number, and no comment indicating that the programmer chose this number for a reason. Comments would've been good, but "hiding" these magic numbers behind a symbolic constant would've better, imo. It would have at least told me that he had put some thought into it rather than hitting random numbers on his keypad.
Lets also consider the fact that, often, documentation external to the code itself is often needed. So much for orthogonality. If the code changes, you have to change the comments. If the comments change, you have to change the external documentation. In more modern languages (like Java w/ javadoc, and some .NET languages (C# at least) w/ XML documentation) this is largely eliminated.
Sorry for the long post. I'd be interested in hearing some opinions on this. Obviously the need for comments in C, or C++ is probably greater than say in Java, VB, etc., but the same idea applies to all. Are the days of transposing PDL directly to code gone, and if so, why do people feel self-documenting code needs to be further documented?
People always ask, "do you comment your code?" I now ask, why do you comment? My manager was more or less flabbergasted when I stated, "I comment as needed only." I made the argument that if I'm having to comment the fundamentals of the language itself, then whoever is looking at the code shouldn't be touching it anyway. I also put forth the argument that in certain languages, comments can be extremely harmful. I can't tell you how many times I've found comments that were completely outdated, and didn't reflect the actual behavior of the code in question. This gives a false sense of security in comments. Also, I /constantly/ see comments in code that are almost exactly the same as the code itself! If a programmer has trouble understanding the basic fundamentals of the language, or programming itself, no comments are going to help him. Recently I was maintaining a project written recently that had calls to SleepEx() scattered throughout, each time with what seemed like a completely random number, and no comment indicating that the programmer chose this number for a reason. Comments would've been good, but "hiding" these magic numbers behind a symbolic constant would've better, imo. It would have at least told me that he had put some thought into it rather than hitting random numbers on his keypad.
Lets also consider the fact that, often, documentation external to the code itself is often needed. So much for orthogonality. If the code changes, you have to change the comments. If the comments change, you have to change the external documentation. In more modern languages (like Java w/ javadoc, and some .NET languages (C# at least) w/ XML documentation) this is largely eliminated.
Sorry for the long post. I'd be interested in hearing some opinions on this. Obviously the need for comments in C, or C++ is probably greater than say in Java, VB, etc., but the same idea applies to all. Are the days of transposing PDL directly to code gone, and if so, why do people feel self-documenting code needs to be further documented?