Mark is a graph advocate and field engineer for Neo Technology, the company behind the Neo4j graph database. As a field engineer, Mark helps customers embrace graph data and Neo4j building sophisticated solutions to challenging data problems. When he's not with customers Mark is a developer on Neo4j and writes his experiences of being a graphista on a popular blog at http://markhneedham.com/blog. He tweets at @markhneedham. Mark is a DZone MVB and is not an employee of DZone and has posted 532 posts at DZone. You can read more from them at their website. View Full User Profile

Essential and Accidental Complexity

03.19.2010
| 4573 views |
  • submit to reddit

I've been reading Neal Ford's series of articles on Evolutionary architecture and emergent design and in the one about 'Investigating architecture and design' he discusses Essential and accidental complexity which I've previously read about in Neal's book, 'The Productive Programmer'.

Neal defines these terms like so:

Essential complexity is the core of the problem we have to solve, and it consists of the parts of the software that are legitimately difficult problems. Most software problems contain some complexity.

Accidental complexity is all the stuff that doesn’t necessarily relate directly to the solution, but that we have to deal with anyway.

I find it interesting to consider where the line is for when something becomes essential complexity and when it's accidental complexity although Neal suggests that there's a spectrum between these two definitions upon which a piece of complexity sit.

I recently read 37 signals book 'Getting real' and one of the things that really stood out for me was the idea of keeping an application simple and writing less software wherever possible.

I'm intrigued as to where this would fit in with respect to essential and accidental complexity because quite often we end up implementing features which aren't part of the application's core value but do add some value yet become way more complicated than anyone would have originally imagined.

Quite often these won't be the first features played in a release because they're not considered top priority and therefore when they are played the amount of analysis done on their potential impact is often less and as we implement these features they end up pervading across the application and increasing its overall complexity.

Another thing that often happens is that we start developing these features, complicating the code base as we go, before the business eventually decides that it's not worth the time that it's taking.

By this time the complexity has spread across the code and it's quite difficult to get rid of it cleanly.

What typically seems to happen is that some of it will just end up staying around in the code base pretty much unused and confusing people who come across it and don't understand what it's being used for.

If we were coming from the angle of Domain Driven Design then we might say that any complexity in the core domain of our application is essential and we should expect that complexity to exist.

On the other hand perhaps we should be more strict about what complexity is actually essential and try and ensure that only complexity around the absolutely vital features is allowed and look to compromise on simpler solutions for features which play a more supporting role.

If we were to follow a definition along these lines then I think we would recognise that there is actually quite a lot of accidental complexity in our applications because although some complex features do contribute to the solution it probably causes more pain than the value that it adds.

The take away for me is that we should be aware that this type of accidental complexity can creep into our applications and make sure that the business knows the trade offs we are making by implementing these types of features.

From http://www.markhneedham.com

Published at DZone with permission of Mark Needham, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Chris Ainsley replied on Sat, 2010/03/27 - 3:34pm

Thanks for the article, a good read.

The first iteration of a solution to a problem is usually both over-complex and not generic enough. I tend to prototype my first instict and if I find my solution starting to feel 'complex' I go back to the drawing board and try to evaluate if the complexity is avoidable without sacrificing the essential requirement. If it isn't then I choose that very moment to document the essential complexity. Anything that is not obvious in code should be documented in code.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.