DEV Community

Nic
Nic

Posted on

Whether to update old code

I was updating my portfolio recently, and wanted to make a few changes, as well as updating the projects on it. Going through my SCSS some of my choices were... interesting. Logical at the time, but looking back on it with more knowledge, I went a bit overboard with mixins.

I thought about changing it, considered the amount of code and the amount of time it would take me. I thought about my list of other projects I want do and things I want to learn. In the end I decided it wasn't so wrong it needed fixing - after all it works and didn't take long to figure out what was going on.

Something similar happened at work. I had to make some updates on the first thing I ever wrote in jQuery, a couple of years before. By this point I was a lot better at it and we'd developed a house style, after we'd all learnt jQuery at the same time.

What I'd written back then was terrible. It was mostly one, very long, function. Some of my variables had more than one name. It was just hard to read. But it worked, so no one had touched it - we had so many things on our never-ending to do list that fixing things that aren't broke didn't make the cut.

Until we needed to make some changes.

Having looked through my old code, I decided that writing it again, incorporating the required updates, would be quicker than just updating it. It wasn't like I was writing it from scratch - there was code in there I could re-use. And after I'd done it, we had code that anyone could understand, because it was much like all our other code.

So the answer to the question of whether to update old code is: it depends. Like all things in coding, there is rarely one hard and fast rule.

Top comments (0)