hm...my .02: The different concrete builder classes can have different interfaces, so if you pass back a product, it might look different depending on what the director built (is it a car, bus, bicycle, etc) The client need to tell the director what he should build, and he controls that by passing the correct builder to the director.
using your solution the client would still need to tell the Director what he wants (e.g. pass a string "car"), and the Director would instantiate the carbuilder, etc. But that would mean that whenever you want to add new products (e.g. aircraft), you have to create an AircraftBuilder, as well as update the Director so that the director actually can create an Aircraft. With the GoF solution, there are no need to change the Director class whenever a new concrete builder is added. cheers, Carl Åsman -- Freelancing software engineer www.edlin.org Holger Mügge wrote: > > in the builder pattern typically the client directly fetches the built > product from the concrete builder calling the getResult() method (cf. > the seqence diagram I attached). > > I wonder whether it would be better to let the director do this and > return the product in its contruction method. I see two advantages: 1. > the client does not have to know the concrete builder, 2. no > synchronization is needed in case the client and the director work in > parallel. Do I overlook something? > _______________________________________________ patterns-discussion mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/patterns-discussion
