Understand Design Patterns with Simple Pythonic Code
A design pattern is based on an Object Oriented Design(OOP) paradigm. Through facing the common issues related to objects, the common design pattern is extracted to solve them. The design pattern is categorized into 3 sub-classifications based on kind of problem they solve.
1)Creational Patterns:
The patterns of object creation and instance initialization
- Singleton(vs IBorg)
- Factory Method
- Abstract Factory Method
- Builder
- Prototype
2)Structural Patterns:
The patterns to assemble objects and classes into larger structures while keeping these structures flexible and efficient
- Adapter (=warraper)
- Bridge
- Composite
- Decorator
- Proxy
3)Behavioural Patterns:
The common communication patterns between objects
- Mediator
- Observer
- State
- Strategy
- Template Method
This article summarizes the code of each patterns in simple pythonic way. The code is referring to several web resources and books. If you understand more clearly practices, I recommend to read this book.
Python in Practice: Create Better Programs Using Concurrency, Libraries, and Patterns