Programming by Difference

Reading time:

1–2 minutes

Whenever my schedule permits, I enjoy dipping into a chapter or two of books I have already read. With the CleanABAP book, for instance, I invariably discover interesting details – something that makes rereading it truly worthwhile. Admittedly, some valuable information simply needs to be refreshed because one has forgotten it; that is only human.

Recently, while reading Michael C. Feathers’ book “Working Effectively with Legacy Code”, the term “Programming by Difference” caught my eye in Chapter 8. It is a technique dating back to the 1980s, one that had already faded into obscurity by the 1990s due to certain drawbacks. Unfortunately, one can no longer find much information about this technique on the internet either.

With a bit of research and some conversations with my AI buddy, I was able to uncover the following: The technique revolves around inheritance. You establish a base class and implement extensions or modifications within a class that inherits from that base class. If this approach is applied excessively, the result is the typical problems inherently associated with inheritance.

While exploring this technique, I realized that I quite consciously use inheritance extremely rarely these days. I still encounter inheritance occasionally, particularly in the context of design patterns; however, I rarely apply design patterns myself. In my experience, it is difficult, even for the original developer, to recognize design patterns in retrospect, and many other ABAP developers fail to recognize them altogether. It is a sad reality, but one drawn from my actual professional experience. To ignore this fact would only serve to exacerbate the overall situation.

Instead of inheritance, the recommendation “Prefer composition to inheritance” has significantly made my professional life easier. Every now and then, you simply need a little encouragement to head in a particular direction.