Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Abstract Factory pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Reply Bookmark "Abstract Factory pattern" Watch "Abstract Factory pattern" New topic
Author

Abstract Factory pattern

Suresh Appagundi
Ranch Hand

Joined: Sep 22, 2003
Posts: 44
I need clear explanation and examples on Abstract Factory pattern.
And what is the difference between Factory Method pattern and Abstract Factory Pattern?
thanks in advance.
william kane
Ranch Hand

Joined: Nov 21, 2000
Posts: 260
Originally posted by suriapps suriapps:
I need clear explanation and examples on Abstract Factory pattern.
And what is the difference between Factory Method pattern and Abstract Factory Pattern?
thanks in advance.

Factory pattern is all about delegating the creation of a specific type to a derived class.Abastract factory is used to provide interface for the clients to get products related to each other.
For Ex.
SupplyCarParts(abstract factory) can have methods like
Engine getEngine();
Body getBody();
Wheels getWheel();
Automobile manufacurerA implements methods in SupplyCarParts to return EngineA(a subclass of Engine),BodyA(a subclass of Body),WheelsA(a subclass of Weels) for building carA.
Automobile manufacurerB implements methods in SupplyCarParts to return Engine(another subclass of Engine),BodyB(another subclass of Body),,Wheels(another subclass of Weels) for building carB.
By using an abstract factory you ensure the clients for manufacuterA get only parts for carA and not engine of carA and body of carB.
Implementation of methods in the abstract factory interface can be done in factoy methods.
Hope this helps


Help me!Help you!!!
Mahesh Chalil
Ranch Hand

Joined: Jan 24, 2002
Posts: 147
In simple words, "AbstractFactory is the Factory of Factories".
william kane
Ranch Hand

Joined: Nov 21, 2000
Posts: 260
Originally posted by Mahesh Chalil:
In simple words, "AbstractFactory is the Factory of Factories".

Even more precisely "An abstract factory is a Factory of Factories churing out related products"
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Abstract Factory pattern
 
Similar Threads
Factory Vs Abstract Factory Pattern
factory methods???????
Proxy pattern
factory or abstract factory?
Patterns: Abstract Factory Vs Factory Method