Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What is the difference between builder and factory pattern

466 views
Skip to first unread message

David

unread,
Jan 27, 2004, 11:05:59 AM1/27/04
to
Dear all,

What is the difference between builder and factory pattern ? It seems
the same. Thanks

Regards,
David


Ilja Preuß

unread,
Jan 27, 2004, 11:35:43 AM1/27/04
to
David wrote:
> Dear all,
>
> What is the difference between builder and factory pattern ? It
> seems the same. Thanks

Builder builds one complex object through several method calls. With
Abstract Factory, every method call returns its own little object.

Does that help?


Rod Davison

unread,
Jan 27, 2004, 1:46:14 PM1/27/04
to

The factor pattern defers the choice of what concrete type of object to
make until run time. E.g. going to a restaurant to order the special of
the day. The waiter is the interface to the factory that takes the
abstractor generic message "Get me the special of the day!" and returns
the concrete product (i.e Liver souffle or Chicken caramel)

The builder pattern encapsulates the logic of how to put together a
complex object so that the client just requests a configuration and the
builder directs the logic of building it. E.g The main contractor
(builder) in building a house knows, given a floor plan, knows how to
execute the sequence of operations (i,e. by delegating to subcontractors)
needed to build the complex object. If that logic was not encapsulated in
a builder, then the buyers would have to organize the subcontracting
themselves ("Dear, shouldn't we have asked for the foundation to be laid
before the roofers showed up?")


The factory is concerned with what is made, the builder with how it is
made. Design patterns points out that (page 105) Abstract factory is
similar to builder in that it too may construct complex objects. The
primary difference is that the Builder pattern focuses on constructing a
complex object step by step. Abstract factor's emphasis is on families of
product objects(either simple or complex). Builder returns the product as
the final step, but as far as the Abstract Factory is concerned, the
product gets returned immediately

Hope that helps

--
.................................................
It may be that your sole purpose in life is simply
to serve as a warning to others.

Rod Davison - Critical Knowledge Systems Inc.

David

unread,
Jan 27, 2004, 9:10:38 PM1/27/04
to
Oh I see . Thanks for you help. Thanks a lot.


0 new messages