How do you keep a legacy application up, running, and maintained all while trying to refactor it to a new architecture? We all know that the world isn’t going to stop and let you go off for x months/years to rewrite a legacy system in the new shiny architecture and language/framework. Even if you do get the chance to do that, it likely wouldn’t be a good idea anyway, because even if you did your job perfectly, for that x months of work, you end up with a system that looks exactly the same to customers as it did before you started. Not a very good selling point.
The only real option left open then is a refactor-in-place, where you still have to add functionality and fix bugs in the same system you are trying to rewrite.
If you are really lucky, perhaps your legacy system is already mostly broken out into small-ish pieces that you can tackle one at a time. Maybe your destination architecture isn’t too far off from what some of these pieces already look like, and you can make small changes to get there.
However, it is likely you’re stuck in a position like the rest of us, where your legacy system is one big monolithic ball of mud. There aren’t any clearly-defined small chunks you can tackle one at a time. In this case, your task is not only to pull out small pieces you can work on, but also to create boundaries for those small pieces. Introducing those boundaries then becomes the risky part. How do you rework the transaction semantics of the legacy system to work with your new boundary? You have to juggle picking up something that is small enough to actually finish in a timely manner, but large enough to not have to make too many risky changes. Starting at the edges (the leaves of the object graph) seems to be easier, but there may be something to attacking the heart of the beast too.
We are currently in the midst of this, where we should be refactoring our legacy system towards our new architecture, but we haven’t actually taken any significant steps in that direction. Luckily for us, new features can mostly be driven entirely in the new architecture, with very limited touch-points to the old systems.
Originally Posted on my Blogger site August of 2017