Refactoring the right way: regional, not global

Every single software has some “legacy”, somewhere. You (or someone else) did things differently to what you believe is best to do now. Refactoring is the art of increasing the maintainability of a piece of code.

No refactoring to do?

If you don’t have any refactoring to do, it’s very likely that you are either over-spending (i.e. you spend far too much time on quality for the sake of it) or you don’t realise that you could be much faster.

“Technical debt” is complete part of the development process and especially in fast-moving environments such as startups where the focus is more much on trying things. As nicely stated in this article:

It’s called technical debt, because it’s like taking out a loan. You can accomplish more today than you normally could, but you end up paying a higher cost later.

“Global” refactoring (don’t do this)

Global refactoring means you will replace an entire layer of your software. Let me give you a few examples:

These examples are good ideas. It might even be needed to do what they describe. The approach (replace) is wrong, though. Doing so (replacing the existent) will require you to change a huge amount of things at the same time and you can be pretty confident that you’ll face the following issues:

To refactor effectively, you need to refactor bit by bit, per region.

“Regional” refactoring

Do it, per “region”, not per layer. A region is one or a set of feature, while a layer is for example the “front-end” or the “validation” or the “storage”, etc… You need to refactor entirely (i.e. all the things you believe needs to be refactored) on one single region of your code.

The interests are multiple:

How do I chose the region? The point of refactoring is to ease the maintenance and usually to increase the quality (from a user/client perspective). Go and refactor the most painful region of your code.

Really, refactor a small region of your code, well. Ship this regional refactoring as fast as possible. And iterate again. :)

Written by

Software Engineering. Containers. APIs & IPAs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store