Designed Inheritance vs. Open Inheritance

time to read 2 min | 256 words

Fowler talks about Designed Inheritance, and he quotes the best argument for it that I have heard so far:

The point here is that "APIs are written by experts for non experts". The library writer should be well versed in the technology that the library works with. She should work to simplify this technology for library users. Encapsulation is all about hiding secrets, so a good library should hide all sorts of complications and danger points from library users, whether they use that library though calling or inheritance.)

That is a very good reason to use designed inheritance, if you assume that your users are non experts. However, I really don't like the fact that you make this assumtion. Especially for framework (or library for general consumtion) building. There are experts who need minute control over every aspect of the library.

There is a reason why Rhino Commons has a [ThereBeDragons] attribute. There are things that I didn't think about when I wrote the class, and I expect users to go beyond what I meant (otherwise, what is the point?). They know that by going beyond the normal parameters of the library, they may get unexpected results.

It seems that this is what Fowler is talking about when he comments about "un-sealing" the class. Something that I would dearly love to be able to do.