Re: Difference between Factory and Abstract Factory
- From: AndyW <a@xxxxxxxxxx>
- Date: Tue, 27 Mar 2007 12:48:11 +1200
On 25 Mar 2007 08:47:10 -0700, EvilOldGit@xxxxxxxxxxxxxx wrote:
I've read the gang of four, and various things I've googled, but I'm
just too stupid to really get the difference between a factory and an
abstract factory.
Help me please...
Unfortunately I think the GOF book was written in Obfusticated Geek
rather than in plain english. I find it muchly confusing myself (so
below is just my interpretation).
As I understand it "Factory Method" is just used to create object of
the same kind (ie. Cats) that have different variations (ie. breeds of
cats). The GOF book refers to Cat as being the Abstract Product and
say RedCatWithFur as the Concrete Product.
Cat * MakeTheKittah( color ) {
Switch( color ) {
case red: return MakeRedCat();
case blue: return MakeBlueCat();
}
}
An Abstract Factory as far as I can see is simply a factory method
that contains many factory methods (in other words its dealing with
abstractions). For example CreateAnimal( int animalType) would
contain factories for MakeCat, MakeDog, MakeRabbit. The GOF book
refers to the CreateAnimal method as being the Abstract Factory, and
the MakeCat, MakeDog etc as being the Concrete Factory.
Animal * CreateAnimal( int type, int color ) {
switch( type ) {
case cat: return MakeTheCat( color );
case dog: return MakeTheDog( color );
}
}
The problem is that they use the term Concrete Factory in one place
and Factory Method in another place which I find confusing.
----------------
AndyW,
Mercenary Software Developer
.
- Follow-Ups:
- Re: Difference between Factory and Abstract Factory
- From: RichardETVS
- Re: Difference between Factory and Abstract Factory
- References:
- Difference between Factory and Abstract Factory
- From: EvilOldGit
- Difference between Factory and Abstract Factory
- Prev by Date: Web based sequence diagram generator
- Next by Date: Re: Oracle buys Tangosol -- Beginning of the end for RDBMS
- Previous by thread: Re: Difference between Factory and Abstract Factory
- Next by thread: Re: Difference between Factory and Abstract Factory
- Index(es):
Relevant Pages
|