Builder
Known Uses
The RTF converter application is from ET++. Its text
building block uses a builder to process text stored in the RTF
format.
Builder is a common pattern in
Smalltalk-80:
-
The Parser class in the compiler subsystem is a Director that takes a
ProgramNodeBuilder object as an argument. A Parser object notifies
its ProgramNodeBuilder object each time it recognizes a syntactic
construct. When the parser is done, it asks the builder for the parse
tree it built and returns it to the client.
-
ClassBuilder is a builder that Classes use to create subclasses for
themselves. In this case a Class is both the Director and the
Product.
-
ByteCodeStream is a builder that creates a compiled method as a byte
array. ByteCodeStream is a nonstandard use of the Builder pattern,
because the complex object it builds is encoded as a byte array, not
as a normal Smalltalk object. But the interface to ByteCodeStream is
typical of a builder, and it would be easy to replace ByteCodeStream
with a different class that represented programs as a composite
object.
The Service Configurator framework from the Adaptive Communications
Environment uses a builder to construct network service components
that are linked into a server at run-time. The
components are described with a configuration language that's parsed
by an LALR(1) parser. The semantic actions of the parser perform
operations on the builder that add information to the service
component. In this case, the parser is the Director.