Object Oriented Programming Design Patterns In JavaScript
Creational patterns
Creational mechanisms to create objects suitable for the sutiation they are working in. Constructor, Factory, Abstract, Prototype, Singleton, Builder
Structural patterns
Concerned with composition - identify simple ways to realize relationships (think dependency) between objects. Ensure that a part of the system can be changed without causing the requirement to make changes in other parts. Assist in recasting parts of the system which don't fit a particular purpose into those that do. Decorator, Facade, Flyweight, Adapter, Proxy
Behavioral patterns
Stremaline the communication between objects. Iterator, Mediator, Observer, Visitor
Creational
- Factory - Creates instance of several types (classes) based on interfaced data or events.
- Abstract factory - Creates instance of several families of types without detailing concrete types.
- Builder - Separates object construction from representation, always create same type of object.
- Prototype - Initialized instance used for copying or cloning.
- Module - Private state scope achieved with IIFE and closure.
- Singleton - A type with only a single instance with global access points.
Structural
- Adapter - Matches different interfaces - incompatible interfaces can work together.
- Bridge - Separate object interface from implementation.
- Composite - A structure of (simple and composite) objects which makes the total object more than the sum of its parts.
- Decorator - Dynamically add alternate processing to objects.
- Facade - A single class that hides the complexity of an entire subsystem.
- Flyweight - A fine-grained instance used for efficient sharing of information that is contained elsewhere.
- Proxy - A placeholder object representint the true object.
Behavioral
- Interpreter - A way to include language elements in an app to match gramar of intended language.
- Template method - Creates shell of an algorithm in a method, then defers the exacts steps to a subclass.
- Chain of Responsibility -Pass request between chain of object to find the one that can handle the request.
- Command - Encapsulate a command request between a chain of objects to find the object that can handle the request.
- Iterator - Sequentially access the elements of a collection without knowing the inner workings of the collection.
- Mediator - Simplifies communication between classes - prevent classes from refering explicitly to each other.
- Memento - Capture an object internal state to be able to restore it later.
- Observer - A way of notifying change to a number of objects to ensure consistency.
- State - Alter an object's behavior when its state changes.
- Strategy
- Visitor