What are Design Patterns

What are Design Patterns

Ferenc Almasi β€’ 2020 December 10 β€’ Read time 2 min read
  • twitter
  • facebook
JavaScript

Design patterns are tested and well-established solutions to commonly occurring software development problems. They are not tied to JavaScript specifically. They are reusable designs to these commonly occurring problems. Each design pattern has a name and we categorize them into three main categories:


Creational Patterns

Creational patterns are all about object creation. Some well known creational patterns are:

  • Prototype: Lets you create copies of an object by cloning them, without depending on their classes.
  • Singleton: Ensures that a class has only one instance at any given time and provides global access to it.
  • Builder: Lets you construct complex objects, with the flexibility to produce different representations using the same construction mode.

Structural Patterns

Structural patterns are about finding ways to describe the relationship between different entities while keeping them flexible and efficient. Some commonly used structural patterns are:

  • Decorator: decorate your classes and objects with new behaviors by simply wrapping them into special functions.
  • Facade: create a simplified interface to an existing library or framework to ease their usage for common tasks.
  • Proxy: It creates an interface to another object, allowing you to perform certain tasks before or after accessing the object.
  • Composite: compose objects into a tree structure where every object in the tree has the same interface.
The Decorator Design Pattern in JavaScript
Looking to improve your skills? Check out our interactive course to master JavaScript from start to finish.
Master JavaScriptinfo Remove ads

Behavioral Patterns

Behavioral patterns aim to solve communication problems between objects. They tend to improve flexibility and decoupling. Some more well known behavioral patterns are:

  • PubSub: It creates publishers and subscribers, where each subscriber can listen to publishers, and publishers can notify subscribers about changes in your objects.
  • Memento: Let's you save and then later restore the previous state of your objects.
  • Command: Let's you encapsulate the information necessary to perform various parameterized actions.
PubSub in JavaScript: Intro to Design Patterns
What are design patterns?
If you would like to see more Webtips, follow @flowforfrank

50 JavaScript Interview Questions
  • twitter
  • facebook
JavaScript
Did you find this page helpful?
πŸ“š More Webtips
Mentoring

Rocket Launch Your Career

Speed up your learning progress with our mentorship program. Join as a mentee to unlock the full potential of Webtips and get a personalized learning experience by experts to master the following frontend technologies:

Courses

Recommended

This site uses cookies We use cookies to understand visitors and create a better experience for you. By clicking on "Accept", you accept its use. To find out more, please see our privacy policy.