oop - Mixin vs inheritance -


what difference between mixin , inheritance?

a mix in typically used multiple inheritance. so, in sense, there's "no difference".

the detail mix in useful standalone object.

for example, have mix in name "coloranddimension", adds color property , width , height.

now, add coloranddimension a, say, shape class, sprite class, car class, etc. , have same interface (say get/setcolor, get/setheight/width, etc.)

so, in generic case mix in inheritance. can argue it's matter of role of class in overall domain whether mix in "primary" class or mix in.

edit -- clarify.

yes, mix in can considered, in todays modern lingo, interface associated implementation. plain, old, everyday multiple inheritance using plain, old, everyday class. happens specific application of mi. languages don't give mix in special status, it's class designed "mixed in", rather used stand alone.


Comments