There are two rules that sum up my thinking on this. One comes from Joshua Bloch and the other comes from the gang of four:
1) Favor composition over inheritance
2) Inherit interfaces and not implementations
Inheritance is abused in OO programming and allowing multiple inheritance is inviting more abuse. We should program to interfaces and use those to support multiple inheritance. We should combine separate interfaces in a single class in order to provide the appearance of multiple inheritance. On the good side, the author of the original article did write a post script in which he admitted that he could get around his problem by using interfaces. And that is exactly the right way to do it!
1 comment:
I'm reminded of my favorite "computing moment" of all time. I was in an annual user's conference with the owner and developer of an application. After about a 5 minute rant from one user about a particular aspect of the software, including an impasssioned speech about how it should work, the owner smiled and said, "That's not a bug, that's a FEATURE." He then when on to explain why, and it was clear that he'd already "been there, done that" in terms of what the user was saying.
The phrase has been with me ever since.
Post a Comment