3 ms·
I remember the original reason for composition over inheritance to be very specific to Java: you can only inherit one class, but compose your class from multipl
by ffsm8 3y ago
I remember the original reason for composition over inheritance to be very specific to Java: you can only inherit one class, but compose your class from multiple interfaces, each of which can have default implemented methods.
In python you've got polymorphism, mixins etc, so the reason for this suggestion doesn't really apply.
Django heavily uses inheritance for the controllers for example - and it works very well.
- jonnycomputer 3y agoI don't really use mixins either, unless it's required by the libraries I'm using. Partly this is habit on my part (and I came to Python from Java). But there is a lot of functionality in python I tend to make only light use of. Like using decorators. I understand them, but they feel like magic, and imo, make code harder to understand if used too much. Same thing with inheritance and multiple inheritance.