aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes About Factory Pattern and Strategy Pattern. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "About Factory Pattern and Strategy Pattern." Watch "About Factory Pattern and Strategy Pattern." New topic
Author

About Factory Pattern and Strategy Pattern.

Zhou Can
Ranch Hand

Joined: Sep 12, 2002
Posts: 34
What is the difference between Factory Pattern and Strategy Pattern ?
They are much like each other in outline.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
I guess you could think of the Abstract Factory Pattern as the Strategy Pattern applied to Factory Method...
I don't have the GoF book at hand, though...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
The two patterns are nothing alike either in intent or in implementation. What were you reading that convinced you they're the same?
Kyle
[ September 13, 2002: Message edited by: Kyle Brown ]

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Wellcome to the Ranch ZhouCan.
Please read our naming policy and change your displayed name accordingly.
The goal of the Factory pattern is to isolate the creation of an intance from the code that is using that instance.
The goal of Strategy is to be able to try several algorithms/policies to resolve a problem/situation.
[ September 14, 2002: Message edited by: Jose Botella ]

SCJP2. Please Indent your code using UBB Code
Andy Jackson
Greenhorn

Joined: Aug 22, 2001
Posts: 3
Hi,
If you think about it the Abstract factory is a structural pattern allowing different but related objects to be constructed - that's all.
The strategy pattern is behavioural and all the objects created exhibit different behaviours (or strategies - hence the name) for dealing with the problem.
Andy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About Factory Pattern and Strategy Pattern.