Handling trade-offs in SOLID design
You may have heard about designing classes around SOLID principles. SOLID is an acronym for five separate object-oriented design principles:
- The single-responsibility principle
- The open-closed principle
- The Liskov substitution principle
- The interface segregation principle
- The dependency inversion principle
Using these principles can result in well-structured classes. However, the principles should not be applied dogmatically. You should always consider whether each principle represents a good trade-off for the application or library you are building. In this section, you'll learn about each of these principles and the trade-offs related to each, to help you decide to what extent you would benefit from using them.
The single-responsibility principle
The basic idea of the single-responsibility principle is that a class should basically serve one purpose. On the face of it, this is a good general rule, as classes...