Table of Contents
Preface
Part 1: Start with Principles
1
Foundational Design Principles
Technical requirements
Following the Encapsulate What Varies principle
What does it mean?
Benefits
Techniques for achieving encapsulation
An example – encapsulating using polymorphism
An example – encapsulating using a property
Following the Favor Composition Over Inheritance principle
What does it mean?
Benefits
Techniques for composition
An example – compose a car using the engine
Following the Program to Interfaces, Not Implementations principle
What does it mean?
Benefits
Techniques for interfaces
An example – different types of logger
An example – different types of logger, now using Protocols
Following the Loose Coupling principle
What does it mean? ...
Get Mastering Python Design Patterns - Third 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.