Let's say I have two base abstract classes with completely different functionality: Laptop and Smartphone. (Suppose the functionality is completely different). And in my current project I had already many implementations of laptops and smartphones, and they always were completely different.
But suddenly I received a request to add a class that is an implementation of pc-tablet, that is actually have functions of both smartphone and laptop. It is too late to change the base classes, and actually I'm very sure that this pc-tablet will appear only once.
The problem is, I should be able to contain my pc-tablet in the conainer for smartphones, but it should also be laptop, because of the inherited functionality (actually beside that, in some part of the project pc-tablet is used only as laptop, and it doesn't need smartphone functionality. Moreover it is bad to look at pc-tablet as smartphone for that particular part of the project). So I have PcTabletAsLaptop : Laptop class, that is actually a laptop, and not a smartphone.
My solution is to add a wrapper:
class PcTablet : SmartPhone
{
private PcTabletAsLaptop _pcTablet;
// Here goes all the methods of PcTabletAsLaptop as proxies:
public void Call(int number)
{
_pcTablet.Call(number);
}
// .....
}
There are 200+ methods and I want them to be generated automatically from PcTabletAsLaptop.
This solution looks quite complicated. My question is it good, or maybe there are some simplier ways to do that?