mardi 23 mai 2017

Best way to evolve library with method returning enum type as response

I have a .NET library i have to evolve. It has some methods that return a enum as response . For example:

    //v1.0
    public enum Vehicle
    {
        Truck,
        Mini,
        Superbike
    }

    public Vehicle getCar(){
        ...
        return Vehicle.XXX;
    }

In version 2.0 I want to define more Vehicles, so it gets something like this:

   //v 2.0
    public enum Vehicle
    {
        Truck,
        Mini,
        Superbike,
        WaterBike
    }

    public Vehicle getCar(){
        ...
        return Vehicle.XXX;
    }

Many other apps are using this library , so i don't want to break compatibility backwards. I need to migrate (just replace) the library from 1.0 to 2.0 in all the applications without breaking anything. Considering a new type will be returned in getCar() method, old code in the apps will not understand that.

How do you propose to evolve the library? It`s a design question.

Aucun commentaire:

Enregistrer un commentaire