All choices are bad

In programming you often have the choice between  quick and dirty (often copy/paste)  and  smarter and DRY (don’t repeat yourself).  The assumption is that the latter will save you time in maintainance at the cost of some more initial effort.   However, I am convinced that independent of what you choose it will haunt you at some point in time.

It’s not difficult to imagine how copy and paste will haunt you:   things will change… and if it’s one of those things you’ve copy and pasted a million times over the place,  you’re not going to be happy.  Especially if the initial code is not yours, you will have no idea where it has spread and if changing it in one place will fix it everywhere.  (Not to mention the slightly altered cases in some place, which will render a simple search useless)

However, the smarter way can also haunt you. First of all,  ‘smarter’  is also  often harder to understand at first glance.  You need to find out where stuff is defined, as code is less straight forward.  Also, DRY often means generating some output based on a more abstract specification. (either a configuration structure or maybe even a DSL (Domain Specific Language)   That’s all great, until there is a feature that doesn’t fit your framework. (and you WILL encounter this at some point)  You either have to spend a  lot of time to incorporate it cleanly or fix it in an even less elegant way than the one you were trying to avoid.

I’m not going to say you need to stay away from smarter programming, however you must realize that it will not protect you from having to do more work than anticipated for what are essentially minor changes.   Every line of code that you put in, will make it harder for some unknown features to be added later on as you can’t foresee everything.

Tags: , , ,

Leave a Reply