I'm hoping for some tips on creating a project (ASP.NET MVC, but I guess it doesn't really matter) against multiples versions of a service (in this case, actually multiple sets of WCF services).

Right now, the web app uses only some of the services, but the eventual goal would be to use the features of all of the services. The code used to implement a service feature would likely be very similar between versions in most cases (but, of course, everything varies).

So, how would you structure a project like this?

Separate source control branches for each different version? Kind of shying away from this because I don't feel like branch merging should be something that we're going to be doing really often.

Different project/solution files in the same branch? Could link the same shared projects easily

Build some type of abstraction layer on top of the services, so that no matter what service is being used, it is the same to the web application?


So I would use the Adapter pattern here. Abstract the services to an interface that satisfies the needs of your app. And implement the details of that abstraction over the service. I would say this is a useful approach even if you're using one service because it helps avoid leaking the details of the underlying service into your application.

For example, if I want an application to store a file but don't care where it is, I would create an IFileStorage interface like so.

public interface IFileStorage
  void StoreFile(Stream fileStream);

Then, I could provide a DropBoxFileStorage adapter and a LocalFileStorage adapter. Either could be called based on configuration or even user selection.

  • 1
    You can take it one step further by adding the Factory Pattern. Use the factory to create the correct type adapter based on some external signal - like a config file. Now you can write something like IFileStorage store = FileStorageFactory.GetFileStorage(). – Ryan Michela Feb 3 '11 at 22:53

I would go the abstraction route. This way its infinitely expandable with very little management. Anything else like source code branching involves a ton of work that can quickly get annoying.

This is more of a general rule than anything else

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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