Bicycle =Any combination of these part names can now be input to this class dictionary to create a Bicycle Object. The Demeter Suite of Adaptive Software Tools can take a class dictionary definition like the one above and generate both the C++ code needed to instantiate all the class definitions as well as a parser that can read legal input to the class dictionary and build the resulting complex object. For example, the input sentence:<color>Color ";"<parts_list>List( Part ) . PartList ~ { Part "," } . Part : Piece1 | Piece2 | Piece3 | Piece4 | Piece5 | Piece6 . Piece1 = "tire" Piece2 = "handle-bars" Piece3 = "single-frame" Piece4 = "double-frame" Piece5 = "horn" Piece6 = "seat" Color : GreenColor | BlueColor . GreenColor = "green" . BlueColor = "blue" .
blue; seat, frame, horn, tire, tire, handle-bars
can be used to describe a blue single seat bike. A green 2 seater bike can also be created:
green; seat, seat, frame, horn, horn, tire, tire, tire, handle-bars, handle-bars
The class dictionary is independant of the mechanism
that creates the object. The class
dictionary can change over time without
affecting the process by which Bicycle objects are
created.
This method meets both the requirements of the Builder Design Pattern:
When is it still useful to use the Builder pattern described in GOF?