Techniques for Self-Documenting Code

Writing self-documenting code is traditionally thought to involve adding a copious amount of comments. Good commenting certainly is an important technique, but there’s muchmore to it than that. In fact, we should actively avoid comments bywriting clear code that doesn’t need them.

The following sections list important self-documenting code techniques. You’ll notice that they cover similar ground to the other chapters in this first part of the book. That’s not entirely surprising—there are many overlapping characteristics of good code; the benefits of one technique will be seen in several areas of code quality.

Write Simple Code with Good Presentation

Presentation has an enormous impact on the clarity of code. ...

Get Code Craft now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.