Design Pattern's Group Questions > Builder

November 11th, 2006


Separate the construction of a complex object from its representation so that the same construction process can create different representations. -Design Patterns, GoF


1) What is the role of the Director? Why is it separate from the Builder?

2) Do the build methods in the builder return anything?

3) Why do there need to be multiple build methods in a Builder?

4) What are the forces that would compel you to use a Builder?

5) Before the Builder returns the final object, does it validate that it was built sufficiently?



Examples Which are Builders?

1) Email message builder Patterns in Java, Mark Grand


Implement It!

You are the lead programmer at a collection agency. Your task is to create a delinquency notice (object), which could be sent out up to 3 times to a person (depending on how delinquent they are!). The first notice should be nice, the second firm but cordial, and the final downright nasty. The notice has 3 parts:

   the greeting, which takes a first and last name

   the message body, which takes the amount owed and the days delinquent

   the closing line, which takes nothing.

Implement this using the Builder pattern. Is the Builder appropriate here?




   Builder Pattern (Wikipedia)

I'm an "old programmer" who has been blogging for almost 20 years now. In 2017, I started Highline Solutions, a consulting company that helps with software architecture and full-stack development. I have two degrees from Carnegie Mellon University, one practical (Information and Decision Systems) and one not so much (Philosophy - thesis here). Pittsburgh, PA is my home where I live with my wife and 3 energetic boys.
I recently released a web app called TechRez, a "better resume for tech". The idea is that instead of sending out the same-old static PDF resume that's jam packed with buzz words and spans multiple pages, you can create a TechRez, which is modern, visual, and interactive. Try it out for free!
Got a Comment?

Comments ()

 None so far!