2

I am not sure if this is the best subsite to ask this question, but I'm pretty sure it doesn't fit on the normal or facebook SO page...

I've been asked to make a general API for connecting to several Social Media platforms (at the moment Facebook and Twitter).

I have already realised both of them seperately. Meaning I retrieve the data I need from both Facebook and Twitter and hold the data in it's own dataclass. In my case a list of FacebookTimelineItems and a list of TwitterTimelineItems.

now the hard part is taking the parts that are used in both (username, id, message and such) and make 1 general class that is eventually passed on to who/whatever sent the call to my API.

these are two pics of the data classes I have:

http://imageshack.us/photo/my-images/703/facebookdata.png/

http://imageshack.us/photo/my-images/204/twitterdata.png/

probably not 100% correct but it gives an idea what it looks like.

Now I've been having several idea about how to go about and generalize the two, which is harder then I thought at first.

  1. Create an interface (TimelineItem) and let the other classes extend that one. this way I'll always be sure I have a class that contains at least the basic info I need. downside is that deserializing the JSON seems to be a nightmare.

  2. Use the two dataclasses I have and combine them into a new class afterwards, then pass that one back to whoever requested it. This would probably work but I get the idea it's not the best way to tackle this problem, and is pretty dodgy IF I get it working.

Or, in case of the other two being nearly impossible. Keep the two seperated in the front end, and go sit in the corner crying because I've just figured out you can't lump together facebook and twitter...

Note: I don't have to make the front end part (view), I just make sure the Model is nicely filled with data :)

I hope I placed this in the right section, if I didn't I apologise and would like to know where I should go with my question.

Thanks in advance for any replied/ideas/opinions on this.

1
  • As a food for thought, windows-mobile "Mango" has such integration in place. They implemented it under "People" hub.
    – Yusubov
    Commented Jun 26, 2012 at 14:42

1 Answer 1

3

Your first approach is likely the correct approach.

Instead of fleshing out why, let me ask you some questions that will lead you to the correct answer.

  • How would you handle integrating another social media site, such Google+, or whatever?
  • Is this code working at the correct layer of abstraction, yet? Offhand, it sounds like implementation details for a particular data feed are biasing your general solution.
  • How would you structure things to simplify writing your front end? Should your front end even care where the data feeds are coming from, so long as it has at least one feed to display?
1
  • I think this is quite a puch in the right direction indeed. I'll give it a swing again today. This time I'll make some more UML and such before starting to move around everything :) Commented Jun 27, 2012 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.