Quality Code Is Assertive

Quality code is assertive—it manages its own responsibilities. Software entities should be assertive, as opposed to inquisitive. This is a code quality I don’t see many people talking about, yet it’s highly valuable in helping to determine where to put behavior and give objects the right responsibilities.

For example, should the code to control printing a document be part of the Document class or part of the Printer class? When I ask developers this question their immediate answer is usually to say the Printer class should have the code to control printing the document, but let’s think about this for a moment. When we consider who knows about the document to be printed, it becomes clear that only the Document class ...