Linked by R_T_F_M on Thu 13th Sep 2012 21:19 UTC
Permalink for comment 535115
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.
Features
Linked by Thom Holwerda on 05/24/13 17:26 UTC
Linked by Thom Holwerda on 05/21/13 21:38 UTC
Linked by Thom Holwerda on 05/20/13 11:29 UTC
Linked by Thom Holwerda on 05/18/13 21:33 UTC
Linked by David Adams on 05/16/13 4:23 UTC
Linked by Thom Holwerda on 05/11/13 21:41 UTC
Linked by Thom Holwerda on 05/08/13 14:22 UTC
Linked by Thom Holwerda on 05/02/13 15:28 UTC
Linked by Thom Holwerda on 04/29/13 21:06 UTC
Linked by Thom Holwerda on 04/24/13 22:24 UTC
More Features »
Sponsored Links



Member since:
2009-02-19
Java was initially designed around inheritance abuse. Inheritance is all over Java's oldest APIs; note for example that Java's original Vector class holds Objects (and not a specific type), which means that you can shove any java Object into them, and that you can't shove a bare scalar type into them (yes, I know that Integer is an object that just thinly wraps around an int). This makes these things extremely type-unsafe; if you want to constrain the types you put in a Java vector, you have to enforce those constraints yourself explicitly, in your code, and you always have to explicitly type-cast the things you get out before you use them. Essentially, Sun was trying to use polymorphism to provide a flexible, generic container without actually including generics in the language, and the result was a mess.
And while Java has proper generics now, that heritage is definitely still in the language. Java by design puts a lot of weight classes, objects and polymorphism.
I might also point out that, at least at my school, we actually teach in some of our courses that "inheritance is a functionality extension and code-reuse mechanism, and you should use the hell out of it." And while I think that's insane, I think that view is one of the fundamental assumptions that went into Java.
Sadly, many developers don't know any better, and you tend to be forced to abuse inheritance as soon as you start incorporating a lot of 3rd party libraries.
In C++ you can find such examples in ATL, MFC, OWL and TurboVision and most game engines.
OOP and inheritance is sometimes the right metaphor, but not always. It's great in game engines, because you often find yourself building large trees of heterogenious but semantically-related types (i.e. large trees of objects that are renderable, but have different render methods). Ditto for UI frameworks, where you find yourself adding lots of different types that are all widgets. But, "look, this technique is used a lot in C++, too!" is not the same as "look, C++ over-uses this technique!" OOP is Java's central organizing metaphor, whereas C++ is a multi-paradigm language that also supports imperative-style code and template meta-programming where those make more sense.