Are there any downsides to changing the class hierarchy of a class that has been in the software for a very long time (10+ years) and that is used extensively?
I have a class A, that doesn’t inherit from anything. What I’d like to do is make it inherit from a new abstract base class, and change 2 of its current methods to virtual methods.
I would usually go for it but my coworkers are much more reluctants, so what possible problems could this cause?
thanks
edit :
the reason I want to do this:
We are creating a new module that can take as “source” either the old class A or the newly created class B.
So I am thinking of creating an abstract class SourceofX who class A and B would inherit from.
The “polymorphism” would only be used by new class / method that take a SourceofX object.
If you have better ideas than this, I am all ears
If you really think the new structure is better, then I would go with what Luchian Grigore says, but it isn’t the only option. For example, you can use a proxy:
Now you can use your new function with instances of your old class without having to modify the old class:
If there are lots of places where you need the proxy, then you can write an overload:
which will let you do this: