13 May 2014

Open-Close-Principle considered (practically) useless

Underlying Goal Considered Valuable

In a recent blogpost, the honorable Uncle Bob once again discussed the merits of the famous Open-Close-Principle. Quote:
You should be able to extend the behavior of a system without having to modify that system.
I like and strongly support that idea. It's realization by plugin-architectures is useful in some cases, it's foundation in object-orientation is one of the few useful applications of inheritance. I teach the OCP in classes and advice people inhale it like oxygen in their daily life. It's a beautiful theoretical concept. In practice, it's mostly useless - sigh.

The Nature of Changes in Practice

Since more than 20 years I work with teams changing, enhancing or optimizing software systems. I've seen code in financial industry, insurance and banking systems, logistics, telecommunications, embedded systems and, of course, the web. Changes were often corrections to previous requirements: (I quote real customers and product-managers in the following lines)
  • "aargh - we didn't mean it THAT way, please correct it to THIS way".
  • "Make it faster, whatever it takes."
  • )
  • "We need some new attributes in the view"
  • "You have to integrate the XYZ system urgently into our processing" (replace XYZ by SAP(c), Oracle(c) or any huge commercial software suite that you cannot integrate by just calling a simple API)
Too bad those requirements cannot be met by simply creating a new plugin to a nice-and-beautiful plugin architecture. Too bad those requirements often invalidate yesterdays' assumptions and code. The open-close-principle does not help me in those cases. Those cases are the rule, the standard, normal. Even if I (or other software engineers) had implemented plugin architectures - those wouldn't help with new attributes in some strange old-school UI or some backend insurance database.

Is Open-Close Applied in Real Systems?

Most productive systems I met (and I met many many dozens of them) don't have the notion of clear extension points. Many have been implemented by teams under severe cost or time restrictions without freedom to apply design principles - sigh again. That's one reason we founded aim42 - to systematically improve (and hopefully help spread OCP application..). @Uncle Bob: Thanx for your design principles - they make this (software) world a better place...