December 23, 2008

The entropy of code

Physics deals with an interesting concept called entropy that measures the state of disorder in a closed system. The second law of thermodynamics looselly states that over time a closed system will become more disorderly and chaotic if nothing is done to prevent it. If you haven't been to your basement for a while you can go down there and see for yourself that this is true: Things have become more disorderly and chaotic over time. And you will have to put in some work to get things back in order.

Code is the same - if you don't do something to actively prevent it the chaos and disorder of your code will increase when you work on it. This is why a lot of old code is a mess, nobody has worked actively to keep the entropy low.

Preventing entropy in your code is fairly easy, and it's a good habit to get into. Whenever you write new code for a project make sure you lower the total entropy of the system by beautifying or simplifying something in the codebase. It doesn't have to be the code you've just been working on - the key is to lower the entropy of the whole system.

If you work actively to keep the entropy of your code low it age gracefully.

If you made it all the way to the end you must have found it interesting.

Maybe you would want to Subscribe to this blog

0 Comments:

Post a Comment

<< Home