I have two separate classes, ClassA and ClassB, that derive from the same base class, but have different business logic. I need to define a third class, ClassC, that also derives from the same base class. This class will be a combination of the existing two classes, i.e, depending on certain criteria, whenever ClassC’s DoSomething() method gets called, I want to call that method from ClassA or ClassB instead (These are not static methods), based on certain criteria. (Note that for every instance of ClassC, the criteria that determines whether I want ClassA or ClassB logic can change). Is there a specific design pattern that could help me get started with this? Thanks.
Share
I sounds like you need to look at the State or Strategy pattern. What you basically want is delegation rather than inheritance.