OOP
Design Patterns
Creational
- Simple Factory -> getClass()
- Factory Method -> factory with sub classes, eg. getSubClass1(), getSubClass2()
- Abstract Factory, factory of factories, group related factories
- Builder, burger -> addChilly(), addPickle()
- Prototype, clone -> doc.copy()
- Singleton
Structural
- Adapter
- Bridge, composition over inheritance, themes -> search engine
- Composite, polymorphism
- Decorator -> @staticmethod
- Facade, simple command for a complex operation -> go()
- Flyweight, share objects
- Proxy
Behavioral
- Chain of Responsibility, bank, PayPal, bitcoin
- Command, remote control, waiter, transaction system, roll back
- Iterator -> python iter
- Mediator, WhatsApp, bank transfer, client-server
- Memento, remember, editor, ctrl+z
- Observer, job alerts, stock alerts, email alerts
- Visitor, open/closed, car parts check, AST
- Strategy, sorting strategy
- State, editor state, bold, italic
- Template Method, ABC
Hacker Laws
🎰