Refactoring: Why The Bother?

When I was learning JavaScript, a new concept came up that I hadn’t heard of before when I learned HTML, CSS or even VBA. Refactoring.

The word alone doesn’t really mean anything to anyone, but mention the word to a software developer or programmer and you’re likely to see at least a glimmer or recognition and maybe a hint of resentment.

Refactoring is the process of auditing code that has already been written and works to find ways to optimise or improve it in some way. Refactoring can include moving repetitive functions into loops, rewriting inefficient blocks of code and even simply adding comments that explain the aim of a particular section of code.

When the code is already doing what it needs to, why would you want to bother with refactoring? Well, one reason is that as you write more and more code, you become more proficient at it and provide better solutions to problems you’ve encountered before. One of the best methods of making sure your newfound knowledge sticks is to apply it as much as possible, so revisiting old code to apply your new skills not only makes the old code better, but makes you better.

Another reason to refactor is that you may have to hand over the code or project to other people. In development, at some point you are probably going to take some shortcut or write your code in such a way that it makes sense to you but is a bit un-intuitive for other people. Do them and yourself a favour and clean up and comment your code!

magic_cleaning

For me, refactoring isn’t something just limited to writing code. I refactor my Excel spreadsheets so that they can be used more easily by other people, adding error checks, automated data input buttons or indicators that show where things go. I’ve also refactored a couple of my older blog posts on here as I’ve written more and become more comfortable with my writing style.

So today what I am admitting is that I am refactoring some of my older blog posts, because I have developed better writing skills than I had in the beginning and I want as much of my work on here as possible to reflect the kind of writer I am now as opposed to the kind of writer I was when I began this blog in June.

Refactoring, it keeps you sharp!

Tell me what you think

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: