Skip to content

Instantly share code, notes, and snippets.

@dungvtdev
Created December 9, 2016 11:20
Show Gist options
  • Save dungvtdev/7e3a7242f6d079d52ad05dfb2f5ecfdb to your computer and use it in GitHub Desktop.
Save dungvtdev/7e3a7242f6d079d52ad05dfb2f5ecfdb to your computer and use it in GitHub Desktop.

Design Pattern

  • Must Know Patterns

    • Command Pattern
    • Decorator Pattern
    • Observer Pattern
    • Iterator Pattern
    • Delegation Pattern.
    • Constructor Pattern : In JavaScript almost everything is an object. We often need to create objects. There are 2 ways to create object. (1) object literal notation. (2) Using new operator.
    • Modular Pattern : This is used to emulate the concept of classes in JavaScript. A class/module in JavaScript is coded with the help of function expressions. This helps to break code in modules such that some of the variables and methods are private to the modules and other are public and exposed as API to other modules.
    • Publish/Subscribe : PubSub promotes lose coupling and is easier to scale. One thing to keep in mind that since subscribers and publishers are loosely coupled, if any subscriber fails due to any any exception the publisher won't even know.
    • MVC : MVC is one of the most important design pattern to understand in today's JavaScript world. The system is divided into three components Model, View and Controller. Model–view–controller
  • Good to Know :

    • Flux : This is an architecture promoted by Facebook. This is mostly used with React library but it is an architecture and not coupled with React. This promoted unidirectional flow of data and makes it easy to reason about the state of application at any point of time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment