Giter VIP home page Giter VIP logo

js-design.patterns's Introduction

JavaScript design patterns

Here you will find most usefull (in my opinion) design patterns implemented in JavaScript. Enjoy! :)

Creational

  • Constructor functions that can be used to instantiate new objects
  • Factory factory simply generates an instance for client without exposing any instantiation logic to the client
  • Prototype In this, we use a sort of a “skeleton” of an existing object to create or instantiate new objects.
  • Singelton pattern where only one instance of a class can exist.
  • Abstract Factory factory that groups the individual but related/dependent factories together without specifying their concrete classes
  • Builder separate the construction from its representation. Useful when there are a lot of steps involved in creation of an object.

Structural

  • Adapter lets you wrap an otherwise incompatible object in an adapter to make it compatible with another class.
  • Bridge decouple an abstraction of object from its implementation so that the two can vary independently
  • Composite composes objects into tree-like structures to represent whole-part hierarchies
  • Decorator lets you dynamically change the behavior of an object at run time by wrapping them in an object of a decorator class.
  • Facade provides a simplified interface to a complex subsystem. (jquery)
  • Flyweight minimize memory usage or computational expenses by sharing as much as possible with similar objects. (memoization, cache)
  • Proxy provides a placeholder for another object to control access, reduce cost, and reduce complexity.

Behavioral

  • Chain Of Resp Request enters from one end and keeps going from object to object till it finds the suitable handler. (even propagation)
  • Command provide the means to decouple client from receiver. (Reciver, Command, Invoker)
  • Iterator way to sequentialy access the elements of an object without exposing the underlying presentation.
  • Observer defines a dependency between objects so that whenever an object changes its state, all its dependents are notified. (Pub/Sub, Observables)
  • Visitor let's you add further operations to objects without having to modify them.
  • Mediator control the interaction between two objects (chatroom, users)
  • Memento capturing and storing the current state of an object in a manner that it can be restored later on in a smooth manner. (edit ,save, restore)
  • State lets you change the behavior of a class when the state changes. (waiting for payment ,procesing, shipping)

js-design.patterns's People

Contributors

jeznacki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.