O'Reilly logo

Design Patterns in C# by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 15. Builder

The BUILDER pattern moves the construction logic for an object outside the class to instantiate. There are several reasons why you might make this move. You might simply want to reduce the size of a class that has many methods. You might also want to allow step-by-step construction of a target object. This occurs when you acquire the parameters for a constructor gradually, as happens with parsers and may happen with a user interface.

An Ordinary Builder

A common situation where you can benefit from BUILDER occurs when data that defines a desired object is embedded in a text string. As your code looks through (that is, parses) the data, you need to store the data as you find it. Whether your parser is XML-based or hand-crafted, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required