0

I know that Python allows multiple inheritance, but I never used it, partly because I consider this as a pretty bad practice.

However, I'm making a GUI and got the following idea...

In this example it is a chess GUI : there is a Board class for the business aspects, a Canvas class which is a tkinter graphical object (but it could be anything else with business classes separated from the graphical ones).

Is it a good idea to make the board graphical object inherit from these two classes ?

class BoardGui(Canvas, Board) :
    ...

My research before asking this question brought me to the Mixin concept, but I'm not sure if it is applicable in this case.

PS : I'm new in stack overflow, feel free to edit my question if necessary, or to send me any feedback, for instance if you think that I'm getting too precise, or too much philosophical, or...

  • As a new user, start with the [tour] and read [ask]. In any case, there's one thing that strikes me: You seem to know enough to consider multiple inheritance bad practice, but now you're asking whether to make an exception here. That simply shows to me that you don't know why MI is considered bad practice by some or that you don't fully understand the reasons. Try to research in that direction. Alternatively, make some experience on your own to get further insight and simply try it out. BTW: Check out Liskov Substitution Principle. – Ulrich Eckhardt May 10 '20 at 16:58
  • Yes, I had already read the tour and how to ask. Thanks a lot for the feedback, it precisely enlightens the point I wanted to figure out here. Better understanding why MI is most often unsuitable and even possibly dangerous is the way, there's some good stack answers [here](https://stackoverflow.com/q/406081/13425151) or [here](https://stackoverflow.com/q/2843755/13425151). In this case, no problems of diamond pattern or methods names' conflicts, but the most reasonable solution would be to use **composition of features, instead of inheritance**. – Nicolas Sénave May 10 '20 at 18:46
  • This question is asking for opinions, which is off-topic for stackoverflow. – Bryan Oakley May 10 '20 at 22:14

0 Answers0