Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

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.

share|improve this answer
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
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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