News for hackers. Stuff that matters.
Re:Why inheritance sucks by zby on Friday August 20, 2010 @08:55AM (#1620239)
This is rather well studied subject - but this article does not add anything to the discussion. It talks a lot about names not much about their meaning. The only explanation he gives for the advantages or modules over classes is <blockquote> 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. </blockquote> as if this kind of unification of variables would obviously solve anything.

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?

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?

Re:Why inheritance sucks by nusco on Friday August 20, 2010 @02:53PM (#1621228)
(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.