Builder'; ?>


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)