Transform Legacy Swift Code

Tips And Tricks

Steven Curtis
7 min readAug 15, 2024
Photo by William Warby on Unsplash

Refactoring legacy code can be a tricky process. Even if the code you are changing seems to be a mess and not fit for purpose you should remember one thing, and that thing is this: The code in production has been tested, approved and has been used by real customers (some bugs can take months or weeks to surface, and the code has been “tested” by real customers if it’s in production).

If you are in the business of changing legacy code (and honestly, we all are if we are producing good quality code at scale) we can use the following tips and tricks for refactoring legacy code.

Legacy Code Background

I believe we should move away from the idea that legacy code is often misunderstood as code nobody wants to figure out or understand (or improve).

We are also in a situation where the language has changed so developers are likely to say that they refactor code rather than rewriting it, and as a result are more likely to be allowed to improve the code.

Remember we are also often told that we are removing code smells from legacy code, but code smells are subjective by their very nature. Remember that some people like the smell of onions and some are repulsed by that smell! We can have inconsistency in these code smells and then have…

--

--