Which design pattern should I be using?
Posted
by Gabriel
on Stack Overflow
See other posts from Stack Overflow
or by Gabriel
Published on 2010-06-09T21:18:07Z
Indexed on
2010/06/09
21:22 UTC
Read the original article
Hit count: 300
design-patterns
Here's briefly what I'm trying to do.
The user supplies me with a link to a photo from one of several photo-sharing websites (such as Flickr, Zooomr, et. al). I then do some processing on the photo using their respective APIs.
Right now, I'm only implementing one service, but I will most likely add more in the near future.
I don't want to have a bunch of if/else or switch statements to define the logic for the different websites (but maybe that's necessary?) I'd rather just call GetImage(url) and have it get me the image from whatever service the url's domain is from. I'm confused how the GetImage function and classes should be designed.
Maybe I need the strategy pattern? I'm still reading and trying to understand the various design patterns and how I could make one fit in this case. I'm doing this in C#, but this question is language-agnostic.
© Stack Overflow or respective owner