|
Hi
Pablo,
The
best answer I've found for this is the following post to comp.object from Robert
Martin (Uncle Bob):
"The
difference is the same as the difference between Strategy and
Template Method. In Strategy we create a whole new class to contain the polymorphic methods we want to call. In Template method we put the polymorhic methods we want to call in our own class, and depend upon derivatives to implement them. In
Abstract factory we create a whole new class to hold the create
methods for the objects we need to create. In Factory Method we put abstract methods in our own class to create objects and depend upon our derivatives to implement them. public
class MyAbstractFactoryUser.
{ public void f() { MyObject o = MyFactory.createObject(); o.doSomething(); } } ============= public class MyFactoryMethoduser { public abstract MyObject createObject(); public void f() { MyObject o = createObject(); o.doSomething(); } } ========== Abstract factories are a little more flexible, but a
little more
complex than Factory methods. You can change factories at runtime, but you can't change Factory Method implementations at runtime. Abstract Factories have to be created by someone, and references to them have to be available to the users. Template Methods live in the using object and are therefore created with it, and always available to it." Hope
this helps,
Bruce
|
- [patterns-discussion] What's your vote for the Grand Ch... Mike Beedle
- Re: [patterns-discussion] What's your vote for the... Dan Palanza
- [patterns-discussion] RE: What's your vote for... Mike Beedle
- [patterns-discussion] Re: [livingmetaphor]... Dan Palanza
- [patterns-discussion] Abstract Factory... Pablo Schor
- Re: [patterns-discussion] Abstrac... Bruce Trask
- Re: [patterns-discussion] Abs... Douglas C. Schmidt
