Introducing the Builder Pattern

The Builder Pattern is part of the group of Creational Patterns and provides us a way to create objects that require a lot of configuration before they reach the point where they can be used. The Builder Pattern is often used for objects that accept many optional parameters in order to define their operation. Another matching case is for the creation of objects where their configuration needs to be done in several steps or in a specific order.

The common paradigm for the Builder Pattern according to Computer Science is that there is a Builder Object that provides one or more setter methods (setA(...), setB(...)) and a single generation method that constructs and returns the newly created result object (getResult() ...

Get jQuery Design Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.