Wednesday, January 02, 2008

Starting over means giving up alot

Sometimes a simple task in code can easily grow to several lines. If it is someone else's code, its common to want to recode it. You know things they don't know. You see a better way to reduce code. You forget about the things they know that you don't know. You forget about the time already invested in testing and troubleshooting the problem.

If you need a script to map a drive and rename it, how long would it take to write it? How long would it take to find the same code that has already seen production? I use that example because the task is simple. You could write that script in as little as 4 lines of code.

I did write that script. It started out at 4 lines of code. Now it sits at over 24. Those extra +20 lines came from the maintenance of the script. That overhead makes it more reusable, simple to use, and has solved the bugs that were only uncovered in production. Now that I write that, I'm not sure 20 lines is enough to handle all that.

But my point is the next guy will have this great desire to recode my script because it can be done in 4 lines of code. Starting fresh means that sometimes you give up all the research and testing that came before. Willing to repeat the same bugs that have already been solved. Willing to resolve all the same problems that have already been solved.

I should have found a script online, but I wanted to do it myself. Some lessons are worth learning yourself.

No comments: