Tuesday, May 28, 2013

Source code experience

Not so long ago I was though about how the code gains its own "experience" over time, You could also refer to this process as „leveling up” mechanics featured in most of RPG games. At first this may sound irrational , but I believe that it's a very common phenomenon and most developers, experienced it at last once during their programming adventure (of course I cannot be sure).

It is possible to go even further, and compare code writing to a RPG game character building and its developement. Your code when you design it is simple, have functionality that you know that are need or you think that they will be need. It's is like creating characters in some RPG games you decide on gender, class, look and some basics parameters. In this point we programmers decide about path that we want to follow with this piece of code and this decision will influence everything later.

Of course hardly ever first decisions are 100% correct. With gaining experience we learn how avoid bad choices but still there are always some mistakes and to overcome them we start to do change in initial plans. In game we would tweak characters so they could pass next enemies. Code is exactly the same you always need to do modifications and cleanups so it be more usable, stable and things like that. Of course you can throw it away and start from scratches but you will loose all this small elements, functions that only wraps some simple operation, error validation and things like that. I called them in this post "source experience" you can call it whatever you want.

They make your code reliable, you know that they not only work but work correct. I don't talk here about hacks because if you have them in your code that mean you cannot relies on it to much. And earlier or later they will remind about themselves.

But what about "Level Up" ? I had such'a situation whit my file system which in some point of development was so stable that I almost didn't do any change in it. But on some point I decide that it could be nicer and do some wrappers that make it's usage easier (your "Level Up"). After that came again time of making small tweaks that make this code really usable.

And I see this pattern often. You code grow with time ( isn't something bad if you do re-factoring ) and your experience. At some point you will catch that you don't touch some things and use them as something natural. Everything because you know that you have there everything you need.

Till next week.

No comments:

Post a Comment