I mean, does the fact that parent class alone is never used anywhere compensate the potential flaws for the critics of the pattern?
Asked
Active
Viewed 62 times
0
-
Well, what are the specific criticisms? Do they still hold in the case of an abstract base class? – Oliver Charlesworth Feb 28 '15 at 19:55
-
2Well, for starters, in Java a class can only have one base class, while it can delegate to multiple other classes. Also, if the parent class isn't referenced anywhere, then it only exists for code sharing, and there are better (less confusing, easier to test, more extensible, etc) ways to share code. The (very) few good counterexamples I've seen are in the collection framework – NamshubWriter Feb 28 '15 at 19:59
-
If you're using Java 8+ then you can use an `interface` with `default` method(s). Does that change your question in any way? What *potential flaws* are you concerned about? – Elliott Frisch Feb 28 '15 at 20:05
-
possible duplicate of [Prefer composition over inheritance?](http://stackoverflow.com/questions/49002/prefer-composition-over-inheritance) – NamshubWriter Mar 02 '15 at 08:21
-
I think the question is well focused on concrete consideration regarding the topic, so I don't believe it exactly matches the more generic one you are referring to – Whimusical Mar 04 '15 at 22:59