The last week or so I’ve noticed a few things about how I interact with code that I’ve written.
Have you ever opened a piece of code (or an entire app) that you wrote some time in the past and wonder what in the world you were thinking when you wrote it? Then did you struggle with whether to rewrite the entire thing or try to fix what you had previously written?
Secondly… how hard is it to delete code that you’ve written. The code works… but you now know how to write better code and feel like you should rewrite the entire app/piece of code.
These two things are generally things that I believe I will need to “grow out of” and “get over” at some point. At this time though, they are both rather difficult to force myself to implement on a daily basis.
Starting Over is Easier at Times
As I learn how to do more and more things with Ruby on Rails, it is often easier to start a new project from scratch that implements the “new stuff” than it is to try to integrate that “new stuff” into an old app.
I know this is something I’ve had to fight in the past as well. As I would build a new WordPress site for a client in the process I’d learn quite a bit of “new stuff.” I would then look at other sites I’d built for previous clients and feel like those earlier sites should really be better.
At times the answer was to start over and rebuild the entire thing for an older client. Most of the times though I was able to convince myself that they paid me to build a site using what I knew at the time. Not what I was going to know in the future. If it is a matter of security however, definitely should be no question. If I write bad code or structure things improperly, that is my issue.
Starting over from scratch usually isn’t the worst thing ever.
You Are Not Your Code
From time to time I experience “code claustrophobia,” code seems to get jumbled (on its own of course) and I can’t seem to follow it very well anymore.
Occasionally at times like this I seriously think it is best to delete and rewrite an entire block of code.
But that brings up another issue. I hate to delete code that took me a few hours to write. Writing code is hard. It’s easy to get attached to your code.
If I work on some particular feature for a couple of hours and then decide that I really should start over… whether because I can’t find the error that causes the code not to load, or possibly because I believe I have a better way to do it. Hitting the actual delete key is rather difficult.
Separating myself from the code that I’ve written. Realizing that it isn’t an extension of who I am… is rather difficult, but I think there is some value to be had there.
Wrapping it Up
Here is what I’m trying to say in a nutshell.
Starting over is sometimes the “more honorable” thing to do – at the same time, you are not the code you’ve written.