'Python interfaces, Design pattern behaviour

  • I have a class A with a lot of functionality
  • Another class is implementing and extending it. The signature of that class is: class B(A).

What I want now is to split the functionality of class A into a class C and D, depenending on the required mode, lets say mode1 and mode2.

  • For mode1: class B(C)
  • For mode2: class B(D)

I'm not so fit with abstract classes, interfaces, design patterns with python and reading through some books did not give me a solution on a per module/class level. What would be a good solution here? Would I still need class A and make class C and D implementing this?

To give some context: Class A has some functionality for model training (which requires a lot of dependencies) and model inference. I want to be able to run my program rather in training or inference mode. This has the benefit that in case of inference I do not need to load all requirements for training

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source