0

Say I have a few 'low-level' classes that implement interaction with different hardware devices or other software components.

I want to provide a high-level 'interface' class. This class would implement a handful of methods that use the lower-level classes to do couple of common tasks.

What is the best way to implement this? Subclassing and multiple inheritance? Or a new class that instantiates the other ones (ie. self._device1, self._device2 etc)?

EDIT I'm sorry, this has been marked as a duplicate, however, I have searched around a lot and have not found a clear answer. Could somebody at least point me to a question of which this is a dupe?

user2364719
  • 15
  • 1
  • 4
  • Questions like this get better answers when you tell us what the use case is. – Robert Harvey Feb 12 '14 at 16:44
  • @RobertHarvey : Especially with the dynamic type in Python, you can use - and abuse - many differents architectures (subclassing, monkey patching, proxy pattern, etc.) when creating interfaces. – lucasg Feb 12 '14 at 16:48
  • The exact use case is controlling a robot-ish electromechanical system. I have a few classes and modules that interface with different hardware components, as well as other bits of code for example communication with another software via tcp. – user2364719 Feb 12 '14 at 16:48
  • 1
    An attractive option might be to use an `abc` as a "mixin" but you're going to need to provide more detail on what your interface is trying to accomplish. – roippi Feb 12 '14 at 16:52

0 Answers0