Saturday, June 11, 2011

Human Constraints and Software Development Best Practices

I'm beginning to see that some of the software development 'best practices' that I've adopted over the years (or aspire to adopt :) ) correlate strongly with some of the unique characteristics of the human mind.  My guess is that this isn't a unique insight but it is one I plan to explore a bit further.

For instance, Studies have shown that humans can hold approximately three to nine things in their head at once.  This number varies somewhat according to what the things are and the person, but it is definitely very small and applies to everyone.

This seems to fit neatly with the best practices of:

  • Having no more than three input parameters per function.
  • Having a function contain no more than seven lines of code.
  • Having a source code chunks (classes/modules) that fits into a single 'page' in an editor (which generally restricts the class/module to containing no more than five to seven fields/methods).
  • The DRY principle (more 'ways' of doing something eats into our Working Memory budget)
  • Having a 'flattened' class hierarchy (using inheritance sparingly and generally preferring composition).
  • In general creating abstractions/groups/blocks/chunks when the underlying number of elements goes much beyond five to ten.
I think this should lead one to be more overtly conscious of taking Working Memory into account when designing and writing software, and perhaps more importantly give a more concrete foundation into why such best practices should be adopted.

I wonder what other 'features' of the human mind play a role in some of our other best practices?

No comments: