In this chapter, we took a step back from the details of Python to look at the SOLID design principles. These considerations are fundamental to how a stateful object should be designed. The principles provide us a useful collection of ideas for structuring an object-oriented design. It seems most useful to consider the principles in the following order:
- Interface Segregation: Build the smallest interface to each class, refactoring to split a big class definition into smaller pieces.
- Liskov Substitution: Be sure that any subclass can replace the parent class; otherwise, consider a composition technique instead of inheritance.
- Open/Closed: A class should be open to extension but closed to direct modification. This requires careful consideration of what extensions are sensible for a given class.
- Dependency Inversion: A class shouldn't have a simple, direct dependency...