News for hackers. Stuff that matters.
Re:Why inheritance sucks by nradov on Friday August 20, 2010 @12:19PM (#1620794)
Composition solves that problem, but I don't know about "nicely". You end up having to litter each class with a bunch of boilerplate methods which simply call the same method on an instance field. This avoids inheritance problems but you can end up with a lot of extra code.

What I would like to see — at least in Java — is a keyword or annotation for instance fields to mark them as pseudo-superclasses. Then the compiler would generate all of those call-through methods automatically, unless overridden in the current class.

Re:Why inheritance sucks by InclinedPlane on Friday August 20, 2010 @12:51PM (#1620877)
It's called the strategy pattern. Look it up.

If you find yourself writing a lot of boilerplate code, you're doing something wrong, whether you're using inheritance or not.

Re:Why inheritance sucks by nradov on Friday August 20, 2010 @12:54PM (#1620889)
Yes, I've read that book too. For many of the cases I deal with the strategy pattern is not appropriate, or creates additional complications. Try again.
Re:Why inheritance sucks by InclinedPlane on Friday August 20, 2010 @05:41PM (#1621721)
Should we raise this discussion to the level of concrete examples? Pastebin perhaps?