Re: Strategy or A factory with Template Method
- From: "H. S. Lahman" <h.lahman@xxxxxxxxxxx>
- Date: Thu, 29 Sep 2005 19:07:38 GMT
Responding to Thinkmind...
Hi Group
I was going through some blogs on the net. Here is one I am looking at.
What's wrong with the following code?
void uploadFiles(Set<File> files, boolean sftp, boolean scp, ...) { if (sftp) { // upload via SFTP } else if (scp) { // upload via SCP } else { // upload via FTP } }
What the author of the blog says to use Strategy Design Pattern to implement this.
But my question is cannot we use a Factory Design Pattern with a Template Method. Which one is more appropriate. Can any one give me idea on this.
Implementing the Strategy pattern will be simpler. B-) All one is doing is selecting a particular behavior to execute based upon context. That sort of selection is exactly what Strategy does so implementing with Strategy would be simple and intuitive.
Perhaps a more basic response is to turn the question around: Why would one want to use a factory pattern here at all? There are no instances being created.
************* There is nothing wrong with me that could not be cured by a capful of Drano.
H. S. Lahman hsl@xxxxxxxxxxxxxxxxx Pathfinder Solutions -- Put MDA to Work http://www.pathfindermda.com blog: http://pathfinderpeople.blogs.com/hslahman (888)OOA-PATH
.
- References:
- Strategy or A factory with Template Method
- From: thinkmind
- Strategy or A factory with Template Method
- Prev by Date: Re: Interface complexity problem in game
- Next by Date: Re: Abstract factory pattern
- Previous by thread: Re: Strategy or A factory with Template Method
- Next by thread: (Slightly)OT : Any patterns/idioms for implementing a decision table in OO language such as Java
- Index(es):
Relevant Pages
|