tags:

views:

140

answers:

2

Hello, 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.

+1  A: 

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
Yeah, I know this problem has been solved. This is really a thought experiment to better myself in OO design.
+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
A: 

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

J.13.L