Summary

The BUILDER pattern separates the construction of a complex object from its representation. This has the immediate effect of making a complex target class simpler. It lets a builder class focus on the proper construction of an object, leaving the target class to focus on the operation of a valid instance. This is especially useful when you want to ensure the validity of an object before instantiating it and don't want the associated logic to appear in the target class's constructors. A builder also accommodates step-by-step construction, which occurs when you create an object by parsing text and may occur when you gather an object's parameters from a user interface.

Get Design Patterns Java™ Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.