4 ms·
multiple inheritance is often misguided. Back in the day that was the major selling point of OO. These days decent languages have composition via roles or tra
by singingfish 11y ago
multiple inheritance is often misguided. Back in the day that was the major selling point of OO. These days decent languages have composition via roles or traits.
- IsTom 11y agoI think the argument mostly still stands. These are still a matter of "taxonomy".
- DonQuixote1000 11y agoIt is just a tool. You must know how to use it. It is your fault if you do not use it correctly. Just like a hammer, it is only approprite in certain use cases.
- TeMPOraL 11y agoSo basically the "progress" of OOP wrt. multiple inheritance looked like this: first we throw it away because it's too dangerous, then we realize it's actually needed for good architecture, so we slowly try to smuggle it in under different names ("traits", "roles", "mixins") hoping nobody will notice.
- PaulKeeble 11y agoIt was refined so that the more common use cases were promoted over and above the problematic ones. Its progressing such that its more useful and more capable of doing what we need.
- agumonkey 11y agoToo much sarcasm. MI was too general, to the point of being more harm than good, so it had to be toned down to find the sweetspot.
- TeMPOraL 11y agoI'm being sarcastic not because I don't understand the rationale, but because of the dogmatic approach of the loudest proponents of those changes.
- singingfish 11y agoI know you're being sarcastic, but here's some contrived MI that shows common behaviour that can in independent taxanomic branches not polluting the inheritance tree [Edit, added a Bird class]: #!/usr/bin/env perl package Flying; use Moo::Role; sub flap { # do stuff; } 1; package Bat; use Moo; with 'Flying'; has wings => ( is => 'ro', default => 2, ); 1; package FruitBat; use Moo; extends 'Bat'; 1; package Bird; use Moo; with 'Flying'; # Implementation left to the reader. 1; use warnings; use strict; use mro; use Bat; use FruitBat; use Data::Dumper; print Dumper mro::get_linear_isa('Bat'); print Dumper mro::get_linear_isa('FruitBat'); print Dumper mro::get_linear_isa('Bird'); __END__ $ perl /tmp/demo.pl $VAR1 = [ 'Bat', 'Moo::Object' ]; $VAR1 = [ 'FruitBat', 'Bat', 'Moo::Object' ]; $VAR1 = [ 'Bird', 'Moo::Object' ];