There are a number of considerations for object-oriented design. In this chapter, we'll take a step back from the details of the Python language to look at a few general principles. These principles provide fundamental guidance on how to design stateful objects. We'll look at concrete applications of the principles in Python.
The general approach we'll follow is defined by the SOLID design principles, which are as follows:
- Single Responsibility
- Open/Closed
- Liskov Substitution
- Interface Segregation
- Dependency Inversion
While the principles have a clever mnemonic, we won't cover them in this order. The Interface Segregation Principle (ISP) seems to be the most helpful for decomposing a complex problem into individual class definitions. Most of the remaining principles help to refine the features of class definitions. The Single...