AllThingsSmitty/basic-design-patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A collection of essential design patterns for software development using practical examples, such Singleton, Factory Method, Observer, and more, to help developers write more efficient and maintainable code.

  1. Abstract Factory - Provides an interface for creating families of related or dependent objects without specifying their concrete classes.
  2. Builder - Separates the construction of a complex object from its representation, allowing the same construction process to create different representations.
  3. Factory Method - Creates objects without specifying the exact class of object that will be created.
  4. Protoype - Creates new objects by copying an existing object, known as the .
  5. Singleton - Ensures a class has only one instance and provides a global point of access to it.
  1. Adapter - Allows incompatible interfaces to work together by converting one interface into another.
  2. Bridge - Decouples an abstraction from its implementation so that the two can vary independently.
  3. Composite - Composes objects into tree structures to represent part-whole hierarchies, allowing clients to treat individual objects and compositions uniformly.
  4. Decorator - Adds behavior or responsibilities to an object dynamically without altering its structure.
  5. Facade - Provides a simplified interface to a larger body of code, making it easier to use.
  6. Flyweight - Reduces memory usage by sharing common parts of the state between multiple objects.
  7. Proxy - Provides a surrogate or placeholder for another object to control access to it.
  1. Chain of Responsibility - Passes a request along a chain of handlers until it is handled or reaches the end of the chain.
  2. Command - Encapsulates a request as an object, thereby allowing for parameterization and queuing of requests.
  3. Interpreter - Defines a representation for a language's grammar and provides an interpreter to process sentences in that language.
  4. Iterator - Provides a way to access elements of a collection sequentially without exposing its underlying representation.
  5. Mediator - Defines an object that encapsulates how a set of objects interact, promoting loose coupling.
  6. Memento - Captures and restores an object's internal state without violating encapsulation.
  7. Observer - Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified.
  8. State - Allows an object to alter its behavior when its internal state changes.
  9. Strategy - Defines a family of algorithms, encapsulates each one, and makes them interchangeable.
  10. Template Method - Defines the skeleton of an algorithm in a method, deferring some steps to subclasses.
  11. Visitor - Separates an algorithm from the objects it operates on by allowing new operations to be added without modifying the objects.

About

πŸ”§ A collection of essential design pattern examples in JavaScript 🧰

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published