I thought I'd blogged about this before but apparently not.
So I'm a fan of both Alan Holub's articles about "Getters and Setters being Evil" and "Why extends is evil". These articles reminded me of an early book by Peter Coad called, "Java Design: Building Better Apps and Applets" which introduced this idea of composition over inheritance. Certainly a predecessor to the whole IoC bandwagon.
In fact, re-reading Holub's article it's interesting in the summary he writes: "As much as 80 percent of your code should be written entirely in terms of interfaces, not concrete base classes. The Gang of Four Design Patterns book, in fact, is largely about how to replace implementation inheritance with interface inheritance."
Likewise, Arthur Riel's, "Object-Oriented Design Heuristics" doesn't ban inheritance but offers the few cases where it is should be used.
Tony Morris (a fellow mouse) has written, "Why extends is not evil". Where he talks about interface inheritance and makes a pretty good point: "The only keyword that is exclusively associated with concrete inheritance is the protected keyword. The use of this keyword should be avoided indiscriminately."
No comments:
Post a Comment