Local rules give global results

DNA and twisty green thingsReading Richard Dawkins’ book The Greatest Show on Earth, I got inspired by his description about genes. He talks about how genes are not the blueprints of the body, but rather a recipe for the body. In other words, the genes do not contain a complete (or even partial) description of the final result, but rather contain various instructions for how to create the body. Each gene contributes only with extremely low level instructions, but these instructions combine in almost incomprehensible ways to form our enormously complex bodies.

I very much liked the idea, that a set of very low level instructions, carefully chosen and carefully followed, could create something so complex and beautiful. Jurgen Appelo has expressed similar ideas regarding complexity theory, and how ant hills or bee hives are complex structures created without a master plan through individual bees’ actions. Yet another connection would be local search algorithms, which find maxima in a landscape through looking only at their immediate surroundings.

Next, my brain started linking these ideas to software development. For example, Test-Driven Development. It is in its essence, a set of very simple rules. Write a test, write needed implementation, refactor. These three simple (at least in theory) steps is all that there is to it, when properly adhered to, it can give great results. Designs tend to be much more easy to use, contain less bloat, be more testable (duh!), and so on. Refactorings are another great example. A set of rules or recipes for how to transform a code base into a better code base.

Obviously, choosing the right set of rules to follow is the important part, as a bad set of rules will lead to crappy code just as an unwanted mutation in a human body may lead to e.g. cancer. But I guess the point I was trying to make is that there is immense power in follow simple rules.