Python Design Patterns - GitHub |
S. No. | Design Patterns | Categories | Definition |
1. |
Singleton Pattern |
Creational |
singleton allows only a single instance of itself to be created and gives access to that created instance. |
2. |
Lazy instantiation in Singleton Pattern |
Creational |
Singleton example. |
3. |
Singleton with metaclass |
Creational |
Singleton example. |
4. |
Factory Pattern |
Creational |
Define an interface for creating an object, but let subclasses decide which class to instantiate. |
5. |
Abstract factory Pattern |
Creational |
Provide an interface for creating families of related or dependent objects without specifying their concrete classes. |
6. |
Facade Pattern |
Structural |
Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. |
7. |
Proxy Pattern |
Structural |
Provide a surrogate or placeholder for another object to control access to it. |
8. |
Adapter Pattern |
Structural |
Convert the interface of a class into another interface clients expect. An adapter lets classes work together that could not otherwise because of incompatible interfaces. The enterprise integration pattern equivalent is the translator. |
9. |
Observer Pattern |
Behavioral |
Define a one-to-many dependency between objects where a state change in one object results in all its dependents being notified and updated automatically. |
10. |
Observer Pattern in Publisher and Subscriber example |
Behavioral |
Observer example. |
11. |
Command Pattern |
Behavioral |
Encapsulate a request as an object, thereby allowing for the parameterization of clients with different requests, and the queuing or logging of requests. It also allows for the support of undoable operations.
|
12. |
Command pattern example. |
Behavioral |
Command pattern example. |
13. |
Command Pattern Example_1 |
Behavioral |
Command pattern example. |
14. |
Template Pattern |
Behavioral |
Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure
|
15. |
State Pattern |
Behavioral |
Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
|
16. |
Model View Controller |
Model View Controller |
Software architectural pattern that divides a given application into three interconnected parts. This is done to separate internal representations of information from the ways information is presented to, and accepted from, the user.The MVC design pattern decouples these major components allowing for efficient code reuse and parallel development.
|