Geek Logbook

Tech sea log book

Refactor or rewrite?

While I was reading The elements of programming style found the following quote:

Don’t patch bad code – rewrite it

The element of programming style – Chapter 4 – Page 1

Its make me think about an informal comments that different professionals have been made during these years: “Don’t touch code that it’s working”. But, in addition, I’ve thanked about the similarities and differences of rewrite code and refactor code. Sometimes this phrases could be used as the same but if we like to be more precise about that we can think that in essence involves different views of the code:

When you refactor the code is supposed you’re going to change the codebase without changing the behavior. So, in this case we are focused in the quality improvements. In the other hand, refactoring involves change the part of the code that it isn’t working or has some flaws, therefore the new code result is different than the previous one.

So, despite the fact that in real world we can use it interchangeably there is a difference in the meaning. When you talk about refactoring you are focusing in improving the structure and quality without changing the functionality, whereas rewriting code is more focused in creating a new codebase.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *.