This is one of the another article in "do I know ?" series. Where we would see different important object oriented design patten details and it's possible implementation.
-
Singleton Pattern
Ref =>- It returns only one object for all set of call.
- There is always a doubt of can create real singleton in python ?
- Ans - https://stackoverflow.com/questions/55860871/restricting-creation-of-object-in-a-singleton-class-using-constructor-in-python
- Implementation : https://github.com/sughosneo/dsalgo/tree/master/src/design_patterns/singleton
-
Factory Pattern
Ref =>- Below example also shows how different object gets created
- Implementation : https://github.com/sughosneo/dsalgo/tree/master/src/design_patterns/factory
-
Abstract Factory Pattern
Ref => -
NULL Object Pattern
Ref =>- Instead of using repetitive NULL object check we can use this Null object pattern during creation of object.
- Implementation : https://github.com/sughosneo/dsalgo/tree/master/src/design_patterns/null
-
Adapter Pattern
Ref =>- Adapter pattern lets you wrap an otherwise incompatible object in an adapter to make it compatible with another class.
- Adapter pattern works as a bridge between two incompatible interfaces
- Implementation : https://github.com/sughosneo/dsalgo/tree/master/src/design_patterns/adapter
-
Decorator Pattern
Ref =>-
Decorating one function call without making any code changes.
-
There are 2 types of it - function and class decorator
-
Implementation : https://github.com/sughosneo/dsalgo/tree/master/src/design_patterns/decorator
-
-
Facade Pattern
Ref =>-
Facade pattern provides a simplified interface to a complex subsystem.
-
One good example would be "When a computer starts up, it involves the work of cpu, memory, hard drive, etc. To make it easy to use for users, we can add a facade which wrap the complexity of the task, and provide one simple interface instead."
-
Implementation : https://github.com/sughosneo/dsalgo/tree/master/src/design_patterns/facade
-
-
Observer Pattern
Ref =>- Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
- This pattern is useful event driven programming to notify the state changed to multiple objects.
- Implementation : https://github.com/sughosneo/dsalgo/tree/master/src/design_patterns/observer
-
Strategy Pattern
Ref =>
[1] : https://medium.com/educative/the-7-most-important-software-design-patterns-d60e546afb0e
[2] : https://github.com/jackdbd/design-patterns
[3] : https://python-3-patterns-idioms-test.readthedocs.io/en/latest/
[5] : https://hackernoon.com/10-oop-design-principles-every-programmer-should-know-f187436caf65