203 private links
Creational
Singleton
Type of object that can be instantiated once
In Typescript, just use a global object, so you don't have the boilerplate.
Prototype
Object.getPrototypeOf
Builder
Build object step by step through different methods instead of using many parameters
Factory
Determine which object to instantiate
Structural
Facade
Simplified to hide low-level details of a system
Proxy
Reactivity system of Vue :D
Replace an original object and do some side effects
Advantage: allow user to work with the proxy just like the original object but it can trigger side effects behind the scene.
Proxy are also used when there is a large object that would be expensive to duplicate in memory.
Behavioral
Iterator
Traverse through a collection of objects.
A pull based system.
An object with a next()
method in javascript that returns a { done: boolean; value: T }
.
Observer
Allow many objects to subscribe to events that are broadcast by another object.
A Subject where other objects subscribe to it and triggers their method when the subject notify
Mediator
In case of many to many relationships, one object is a coordinator between them.
Middlewares are an example of mediator.
State
What is the difference between state and strategy pattern?