This repository contains JavaScript implementation for all design patterns described in the Design Patterns: Elements of Reusable Object-Oriented Software book written by "Gang of Four".
Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (1994). Design Patterns: Elements of Reusable Object-Oriented Software.1.8 How to Use a Design Pattern (pp. 28-29, Table 1.2)
Purpose | Design Pattern | Aspect(s) That Can Vary |
---|---|---|
Creational | Abstract Factory | families of product objects |
Builder | how a composite object gets created | |
Prototype | class of object that is instantiated | |
Singleton | the sole instance of a class | |
Factory Method | create objects in parent class | |
Structural | Adapter | interface to an object |
Bridge | implementation of an object | |
Composite | structure and composition of an object | |
Decorator | responsibilities of an object without subclassing | |
Facade | interface to a subsystem | |
Flyweight | storage costs of objects | |
Proxy | how an object is accessed; its location | |
Behavioral | Chain of Responsibility | object that can fulfill a request |
Command | when and how a request is fulfilled | |
Interpreter | grammar and interpretation of a language | |
Iterator | how an aggregate's elements are accessed, traversed | |
Mediator | how and which objectsinteract with each other | |
Memento | what private information isstored outside an object, and when | |
Observer | number of objects that depend on another object; how the dependent objects stay up to date | |
State | states of an object | |
Strategy | an algorithm | |
Template Method | steps of an algorithm | |
Visitor | operations that can be applied to object(s) without changing their class(es) |
You can run each design pattern implementation by executing the following command in the terminal:
node /<design-pattern-type>/<design-pattern-name>/index.js