The Danger of Outdated Documentation

Comments are good as long as they are current, but an outdated comment causes a lot of confusion. Comments become outdated when they get out of sync with the code they are supposed to be documenting. Is the comment correct or is the code correct? They are confusing, and if too many of them are outdated and incorrect, they will simply be ignored. Outdated comments can be quite dangerous. Whenever you update your code, you should try to remember to update your comments as well. It’s easy to forget to update your comments because the code will still run correctly, even if your comments are inaccurate. Because you will sometimes forget, it’s important to document your intentions. Even if the underlying code changes, ...

Get Learning to Program now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.