Here's the full list of what is covered:
Single Responsibility Principle, Open-Closed Principle, Liskov Substitution Principle, Interface Segregation Principle and Dependency Inversion Principle
Builder, Factories (Factory Method and Abstract Factory), Prototype and Singleton
Adapter, Bridge, Composite, Decorator, Façade, Flyweight and Proxy
Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method and Visitor
- Separate component for when object construction gets too complicated
- Can create mutually cooperating
- sub-builders: Often has a fluent interface
- Factory functions (constructors) are common
- Factory can be a simple function or a dedicated struct
- Creation of an object from an existing object requires either explicit deep copy or copy through serialization
- When you need to ensure just a single instance exists
- Canbe made thread-safe and lazy
- Consider extracting interface or using dependency injection
- Converts the interface you get to the interface you need
- Decouple abstraction from implementation
- Allows clients to treat individual objects and compositions of objects uniformly
- Attach additional responsibilities to objects
- Provide a single unified interface over a set of interfaces
- Efficiently support very large numbers of similar objects
- Provide a surrogate object that forwards calls to the real object while performing additional functions
- E.g., access control, communication, logging, etc.
- Allow components to process information/events in a chain i
- Each element in the chain refers to next element; or |
- Make a list and go through it
- Encapsulate a request into a separate object
- Good for audit, replay, undo/redo
- Partof CQS/CQRS
- Transform textual input into structures (e.g. ASTs)
- Used by interpreters, compilers, static analysis tools, etc.
- Compiler Theory is a separate branch of Computer Science
- Provides an interface for accessing elements of an aggregate object
- Provides mediation services between several objects
- E.g., message passing, chat room
- Yields tokens representing system states
- Tokens do not allow direct manipulation, but can be used in appropriate APIs
- Allows notifications of changes/happenings in a component
- We model systems by having one of a possible states and transitions between these states
- Such a system is called a state machine
- Special frameworks exists to orchestrate state machines
- Both define a skeleton algorithm with details filled in by implementer
- Strategy uses composition; Template Method doesn’t
- Allows non-intrusive addition of functionality to hierarchies