Should I put the main version number in the C # / Java namespace?

I create a set of service-level objects (data objects and interface definitions) for the WCF web service (which will be consumed by third-party clients, that is, not internally, therefore, outside my direct control).

I know that I will not be able to pinpoint the interface. wanting to prepare for the time when I know that I will have to enter a breakdown set of new data objects. However, the reality of the world I'm in is that I will also need to launch my first version at the same time for quite some time.

The first version of my service will have the URL http: //host/app/v1service.svc

and when the time of the new version will live http: //host/app/v2service.svc

However, when it comes to data objects and interfaces, I'm am toying with putting the "main" version of the interface number in the actual class namespace.

namespace Company.Product.V1
{
   [DataContract(Namespace = "company-product-v1")]
   public class Widget
   {
        [DataMember]
        string widgetName;
   }

   public interface IFunction
   {
       Widget GetWidgetData(int code);
   }
}

When the time comes for a fundamental change in service, I will introduce some classes, such as

namespace Company.Product.V2
{
   [DataContract(Namespace = "company-product-v2")]
   public class Widget
   {
        [DataMember]
        int widgetCode;

        [DataMember]
        int widgetExpiry;
   }

   public interface IFunction
   {
       Widget GetWidgetData(int code);
   }
}

The advantages that I see are that I can have one set of code serving both versions of the interface, sharing functions where possible. This is because I can refer to both versions of the interface as a separate set of C # objects. Likewise, clients can use both version interfaces at the same time, possibly using V1.Widget in some legacy code, while new bits go to V2.Widget.

Can someone say why this is a stupid idea? I feel like it's a little smelly.

: , , . , , , , , , , .

, .., , . .

+5
2

, ( V1, V2 Common), . , , Common, V1, V2 .. .

. , API, "" , - - , .

+3

( ) 2 Widget2, IWidget2 .. , v2 () , , v1 , . , , , .

+1

All Articles