Communication with different social networks, strategy pattern?
Posted
by bclaessens
on Stack Overflow
See other posts from Stack Overflow
or by bclaessens
Published on 2010-05-17T07:47:31Z
Indexed on
2010/05/17
7:50 UTC
Read the original article
Hit count: 235
Hi
For the last few days I've been thinking how I can solve the following programming problem and find the ideal, flexible programming structure.
(note: I'm using Flash as my platform technology but that shouldn't matter since I'm just looking for the ideal design pattern).
Our Flash website has multiple situations in which it has to communicate with different social networks (Facebook, Netlog and Skyrock). Now, the communication strategy doesn't have to change multiple times over one "run". The strategy should be picked once (at launch time) for that session.
The real problem is the way the communication works between each social network and our website. Some networks force us to ask for a token, others force us to use a webservice, yet another forces us to set up its communication through javascript. The problem becomes more complicated when our website has to run in each network's canvas. Which results in even more (different) ways of communicating. To sum up, our website has to work in the following cases:
standalone on the campaign website url (user chooses their favourite network)
- communicate with netlog
- OR communicate with facebook
- OR communicate with skyrock
run in a netlog canvas and log in automatically (website checks for netlog parameters)
- run in a facebook canvas and log in automatically (website checks for facebook params)
- run in a skyrock canvas and log in automatically (website checks for skyrock params)
As you can see, our website needs 6 different ways to communicate with a social network. To be honest, the actual significant difference between all communication strategies is the way they have to connect to their individual network (as stated above in my example). Posting an image, make a comment, ... is the same whether it runs standalone or in the canvas url. WARNING: posting an image, posting a comment DOES differ from network to network.
Should I use the strategy pattern and make 6 different communication strategies or is there a better way? An example would be great but isn't required ;)
Thanks in advance
© Stack Overflow or respective owner