The builder creational pattern allows you to hide all the details needed to create a complicated object behind simple steps that another object will direct. This lets you change either how things get built or the steps that are used independently of each other.

This pattern describes how you might have an abstract class called a builder with maybe three methods: addStory, addRoom, and addDoor

The addStory method can be called many times to make the building higher. The builder will decide what needs to be done to support such a short or tall building.

The addRoom method will add a room to a specific story. The director can call this method to add various rooms. The builder will decide how and where to place walls to get the desired effect.

The addDoor method will be called to add a door between two rooms or between a room and the outside.

And this design pattern describes how a client will be the one to actually choose a specific concrete builder class that derives from the abstract builder class. The client also selects a director and provides the builder to the director. The director only knows about the builder through the base class interface.

With this pattern, different directors can be selected that will call the builder methods to direct the construction of various building. And different builder can be selected that will carry out these instructions.

If the client selects a director that knows how to build a simple house in the suburbs but provides a shipBuilder for the builder, then what gets built will resemble a small sized yacht instead of a 3 bedroom house.


What's on your mind?
On a scale of 0 to 10, how likely are you to refer us to friends?