Twitter GitHub Facebook Instagram dirv.me

Daniel Irvine on building software

Needless complexity

1 June 2014

Uncle Bob’s PPP book has a great discussion of needless complexity, which can so easily sneak into our designs when we aren’t paying attention. A common symptom of this is having a set of related classes which are difficult to understand as a whole. Sometimes the entire group could be better expressed as one single class.

One way this can occur is by blindly following the Single Responsibility Principle, the well-known “first law” of object-development, which is really saying that each class should do one thing and one thing only. The PPP book defines it as each class should only have one reason to change.

If you always follow this advice you’ll end up with needless complexity in your design.

So how do you guard against it?

The PPP book has a great answer:

An axis of change is an axis of change only if the changes actually occur.

In other words, don’t try to anticipate where changes will occur since they might never happen. When the time comes that you have to make a change, then you can surmise that further changes are likely to happen across that same axis and you should split the responsibilities accordingly.

About the author

Daniel Irvine is a software craftsman at 8th Light, based in London. These days he prefers to code in Clojure and Ruby, despite having been a C++ and C# developer for the majority of his career.

For a longer bio please see danielirvine.com. To contact Daniel, send a tweet to @d_ir or use the comments section below.

Twitter GitHub Facebook Instagram dirv.me