Design principles
Design patterns help us with some of the issues we’ve discussed regarding making changes, reusability, and maintainability. Using design patterns backed by the experience and different work scenarios of highly experienced forebearers, we can be sure that our code will become more readable, decoupled, and aligned with best practices. From my experience, I can say that design patterns have the power to force us to write clean code.
Let’s cover some of the design principles that stand behind design patterns:
- SOLID principles (as discussed in Chapter 1, The Role of Architecture)
- Encapsulate what varies
- Favor composition over inheritance
- Loose coupling
- KISS
- YAGNI
- DRY
Let’s look at these design principles in detail.
Encapsulate what varies – This principle is one of the most straightforward. It teaches us to identify the areas of our system that vary and separate them from what never changes and...