Pages

Friday, November 08, 2013

The Module Pattern

Modules are an integral piece of any robust application's architecture and typically help in keeping the units of code for a project both cleanly separated and organized.

Different options for implementing modules in JavaScripts are:
  1. The Module pattern
  2. Object literal notation
  3. AMD modules
  4. CommonJS modules
  5. ECMAScript Harmony modules
Advantages of Module Patterns
  • Clean
  • Supports private data
Disadvantages of Module Patterns
  • As we access both public and private members differently, when we wish to change visibility, we actually have to make changes to each place the member was used.
  • Cannot access private members in methods that are added to the object at a later point.
  • Inability to create automated unit tests for private members.
  • Additional complexity when bugs require hotfixes.

No comments:

Post a Comment