0

I'm trying to determine the best design for an application that will access several different social network APIs. Here is an interface that I haven't settled on because it just doesn't feel quite right. I'd like to know what would be a better design approach to this problem...

public interface ISocialNetworkAPI<TApiEntity> where TApiEntity : SocialNetworkEntity
{
    List<TApiEntity> GetAllFollowersFor(string networkUserName);
    List<TApiEntity> GetAllFriendsFor(string networkUserName);
    List<long> GetFollowerIdsFor(long networkUserId);
    List<long> GetFollowerIdsFor(string networkUserName);
    List<long> GetFriendIdsFor(string networkUser);
    TApiEntity GetUser(string networkUserName);
}

I'm also planning on using a DI container to inject the appropriate social network concrete object based on the context of the call.

  • You might look at the adapter design pattern... Each Adapter would adhere to the interface you have above. MySpaceAPIAdapter, FacebookAPIAdapter... – bytebender Apr 04 '09 at 17:30

2 Answers2

2

Have you looked at OpenSocial? It's Google attempts at a standard social network API. Perhaps you should be modelling it off that if not using it outright.

cletus
  • 616,129
  • 168
  • 910
  • 942
  • Yeah, I know this problem has been solved. This is really a thought experiment to better myself in OO design. –  Apr 04 '09 at 13:52
  • +1 - Good answer. Phil, you might want to see this question: http://stackoverflow.com/questions/575217/whats-a-good-example-for-class-inheritance/575242#575242 The task you've given yourself above is way too difficult to serve as a learning task unless you have a lot of experience already. – Mark Brittingham Apr 05 '09 at 00:30
0

You might look at the adapter design pattern... Each Adapter would adhere to the interface you have above. MySpaceAPIAdapter, FacebookAPIAdapter...

bytebender
  • 7,371
  • 2
  • 31
  • 54