Thursday, December 1, 2011

Inheritance hierarchies

In an IRC discussion the comment came up that "deep hierarchies mean you're doing good OO.. um... right?"

That put me in mind of one of my favourite comments on the subject, from Richard Gabriel's 1996 book "Patterns of Software" (in PDF). In the first chapter (Reuse versus Compression) he talks about inheritance not as code re-use, but as code compression. You can express a lot very succinctly by sharing code that way, but you're tightly coupling those things together. Whether that's worthwhile or not depends on the circumstances.

No comments:

Post a Comment