The meek shall inherit…on April 1st, 2012 at 6:10 pm
But the rest of us shall do it properly.
I am, of course, talking about the evil that is inheritance. Time after time, this has tripped up many a seasoned developer, including myself.
I changed my attitude to inheritance about 6 years ago and opted for the much more convenient and flexible route of composition. I guess being a former C++ developer, inheritance had been drummed into me and there was nothing else in the world. As software projects became larger, the more complex object models became and the promise of reuse became a distant memory.
It was then that I thought that this had to change. Instead of building all the functionality into the object models themselves, we should be building specific classes that do the work for us. To work across our object model and update it as it sees fit.
This then came into its own with dependency injection and being able to inject different behaviours instead of having to build more and more complex object models. Reuse was back with a vengeance and so was my fervour.
Anyone still singing the virtues of inheritance….your wrong, so wrong! Mind you, maybe you’re happy being meek.