Re:Why inheritance sucks
by RodgerTheGreat on Friday August 20, 2010 @10:47AM
(#1620510)
Regarding the diamond problem, I think he means that in the event of multiple inheritance, your class heirarchy would look like this:
Object
/ \
A B
\ /
C
Where A and B are parents of the class C. In most OO languages there will be an implied parent of A and B, like Object.
Re:Why inheritance sucks
by kenjackson on Friday August 20, 2010 @11:10AM
(#1620587)
"In Ruby you don't declare your types, so you cannot get ambiguous instance variables: if you have two instance variables with the same name in different modules, then they're the same instance variable."
That line also bugged me. I struggle to see how that's a good thing. That seems like you could have code breaking in seemingly unrelated code due to seemingly common naming issues. That can't be right, can it?
(From the original poster): You're right that I mischaracterized the diamond problem. I edited the post to fix that. My C++ mind model has been slipping away fast in part years. Definitely not like riding a bicycle.
Despite linking to the Wikipedia, he also does provide the right definition of the diamond problem: <blockquote> This is the dreaded "diamond" problem that C++ programmers learn to fear: if your class has two superclasses that both define an instance variable named x, then you can have a hard time specifying which x you're using. </blocquote> Where is the diamond here?