Design Principles and Patterns

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

Get Mastering Object-Oriented Python - Second Edition 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.