1.3. The Guidelines Explored

Our goal as developers is to make understandable, readable, and maintainable code. The guidelines in this book are designed to help you reach this goal. The guidelines presented in this book do not represent best practices. "Best" can be determined only in the context in which you are currently developing a system. However, the guidelines do represent suggestions for creating good practices appropriate to your context.

EXCEPTIONAL GUIDELINE

There are exceptions to every guideline, except this one.

Many of the guidelines are different manifestations of the same basic principles. The underlying principles have tradeoffs in their application, which also appear in the derived guidelines. For example, applying the principle of separation of concerns usually creates more classes and more methods. Consistency, even though it might increase the amount of code, also makes systems that do similar things have the same structure, thus decreasing learning. A concentration on interfaces and delegation increases the number of delegating methods.

1.3.1. Context Is Everything

One rule exists: nothing works everywhere, and hence, you must be the judge if a particular practice is appropriate for your application. You need to apply principles in context . The decision whether to use a particular principle or practice depends on the situation in which it is employed. When you try to apply the same principle or style to everything, you can create waste or confusion. ...

Get Prefactoring 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.