Design patterns in Javascript

Object Creation Patterns:

1. Abstract factory

What is it?
In object-oriented programming a Factory is an object that creates other objects. An Abstract Factory has abstracted out a theme which is shared by the newly created objects.

2.Builder

What is it?
The Builder pattern allows a client to construct a complex object by specifying the type and content only. Construction details are hidden from the client entirely.

3.Prototype

What is it?
The Prototype Pattern creates new objects, but rather than creating non-initialized objects it returns objects that are initialized with values it copied from a prototype — or sample — object.

4.Singleton

What is it?
The Singleton Pattern limits the number of instances of a particular object to just one. This single instance is called the singleton.

Structural Patterns

1. Adapter

What is it?
Translates one interface (an object’s properties and methods) to another.

2.Composite

What is it?
Creation of objects with properties that are primitive items or a collection of objects. Each item in the collection can hold other collections themselves, creating deeply nested structures.

3.Decorator

What is it?
The Decorator pattern extends (decorates) an object’s behavior dynamically. The ability to add new behavior at runtime is accomplished by a Decorator object which ‘wraps itself’ around the original object. Multiple decorators can add or override functionality to the original object.

Behavioral Patterns

1. Chain of Responsibility

What is it?
Provides a chain of loosely coupled objects one of which can satisfy a request.

2. Observer

What is it?
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

3. Iterator

What is it?
Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Suffering from Knowledge Quest

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store