JavaScript – Builder Pattern

GitHub Code

The builder pattern builds a complex object in steps.  The ‘components’ are an invoker, a builder and a series of sub-objects that make a composite object.  While any pattern can take multiple forms, the best description I have found is in reference #3 which is what I have based this sample on.

To Run:

•    Make GET Call
Screen Shot 2017-04-28 at 10.33.33 PM
•    Review Results

Screen Shot 2017-04-28 at 10.33.21 PM
The project is made up of four files.

Screen Shot 2017-04-28 at 10.35.21 PM
This implementation consists of a director, a builder, and a concrete builder.  For my sample, I am going to implement as follows:

•    Director/Invoker – builderDriver.js
Screen Shot 2017-04-28 at 10.36.26 PM
•    Builder – IBuilder.js
Screen Shot 2017-04-28 at 10.36.33 PM
•    Concrete Builder – ConcreteBuilder.js
Screen Shot 2017-04-28 at 10.36.18 PM

Stay tuned!

References
1.    https://en.wikipedia.org/wiki/Builder_pattern
2.    https://sourcemaking.com/design_patterns/builder
3.    http://www.oodesign.com/builder-pattern.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s