Pattern in Large Scale JavaScript Applications (Part -2 of 8)

It is clear from the Part — 1 of the Post that what a Pattern is in the Software Development Process and why we use the Software Design Pattern and the factors for using design pattern in JavaScript.If you haven’t read the previous post, i will recommend you to please read it once to get the overview.

I am very big fan of JavaScript’s Module Design Pattern.That’s the Object Literal Pattern in the category of Modular Design pattern.

What is Module Pattern ?

The Module Pattern is one of the Design Pattern not only in Javascript only that encapsulates PRIVACY & STATE using Closures in

It gives us the way to encapsulate the private and public methods and variables and protect our methods from the Global Scope.

Code Snippet :

Below is the example of Shopping Cart that’s being implemented with the Module Pattern.shoppingCart Module is itself a Global module.
 Cart is an Array that’s Private so that other parts of the module can’t access it directly.

Read Full Article