Disciplined Agile

Core Developer Skills: Avoiding Redundancy

Redundancy must be strenuously avoided in our work. Redundancy increases the cost of maintenance, often by an order of magnitude. A good example of this was the Y2K bug. The problem was not that the issue was complex: 2 digits vs. 4 digits. It was that it was repeated in millions of places throughout systems.

  • DRY (Don’t Repeat Yourself)
  • “Once and Only Once”
  • Avoid redundancy
  • Write concise code

Typically, developers concentrate on duplicated state and functionality (code). However, equal care should be taken to avoid duplication:

  • Relationships
  • Design
  • Object Construction
  • Data
  • Anything else

Benefits

Anything that is redundant in a system will have to be maintained in more than a single place. This introduces the possibility that one or more of these places will be missed during maintenance. Eliminating redundancy eliminates that possibility.

Also, redundancy reduces clarity. If duplication is permitted in a system, seeking an integration point or locating a bug is about trading time to reduce risk; after we find the first instance, we have to keep looking for potential duplicates. If no redundancy is allowed, we can cease the search after finding the first place to make a change.

Eradicating redundancy increases the likelihood that the code will be easy to understand and modify.

Obstacles

A certain amount of redundancy cannot be avoided.

For example, on a platform like Java or .NET, inheritors of abstract classes with constructors must call those constructors. In such a case, a change to the signature of the constructor will trigger a change to all the inheritors.

The limitations imposed by each language are different.

Solutions

Fortunately, we don’t have to find all the places where the coupling was repeated. At best, the compiler will do so and, at worse, we will find out at run-time.

We can also design around problems intrinsic to the chosen platform. For example, we can create value-objects to encapsulate signatures of methods. Or we can hide constructors to ensure there are no redundant calls to them.  

May 2023

Core Developer Skills Overview

Recommended Book

  • McConnell, Steve. Code Complete: A Practical Handbook of Software Construction. 1993.