Code natural selection

Post by Nico Brailovsky @ 2015-04-09 | Permalink | 1 comments | Leave a comment

A funny thought just came to me: if you write nice clean code, it's easy to replace it. Just plug out an object somewhere, replace it with another one implementing the same interface, run the tests. Tada! On the other hand, if you write crappy code it might be nigh impossible to replace it. It will probably be worked around whenever a change is needed, simply adding layers of crust. Maybe that's why legacy code sucks: it's simply code natural selection - and the fittest to survive is simply the crappiest one. I think I'm depressed now.


In reply to this post, Adar commented @ 2015-04-21T11:17:03.000+02:00:

You can look at it from the other side: nice code is more likely to be replicated and used in more projects.

Original published here.