When it comes to migrating applications and services to the cloud, the 6 Rs model is widely accepted: Rehosting, Replatforming, Repurchasing, Refactoring, Retiring and Retaining. Refactoring, also referred to as re-architecting, involves reimagining how an application or service is architected.
Refactoring often involves moving from a monolithic architecture to a service-oriented or serverless architecture. It is typically done to take advantage of cloud-native features and is driven by a strong business need to make changes – such as adding new features, scale, performance and redundancy – which would be difficult to achieve in the application’s existing form.
Budgets and migration timeframes are key factors when deciding whether to Rehost, Replatform or Refactor, such as whether the migration is driven primarily by the desire to make the most of the cloud’s strengths or whether it’s driven more by a pressing need to exit the current environment, such as an on-prem data centre.
A Rehosting ‘lift and shift’ generally takes the least time and requires the least expense, but it also unlocks the least value in terms of taking advantage of the cloud’s strengths. Replatforming is the middle ground, making a few key changes to make an application cloud-ready, but not going as far as refactoring in embracing a truly scalable architecture.
It’s possible to undergo a partial refactoring, which only modifies specific sections of an application to take advantage of the cloud, or a complete refactoring, which changes most of the application.
When evaluating refactoring, it is important to consider the expected retirement date of the application, as well as whether the business would benefit from the proposed changes. Applications that are highly resource intensive and/or don’t run well in their current environment are good candidates for refactoring, allowing for the fact that deconstructing a monolithic application could be complex. You need to consider whether it’s worth the trouble, rather than opting for one of the other Rs.
Code refactoring
Refactoring can also refer to ‘code refactoring’, which involves optimising your code or cleaning up technical debt. It’s often an important step when migrating to the cloud, to ensure you’re not bringing along any issues you’ve previously swept under the carpet.
Code refactoring is not about adding new functionality and features; it is about consolidating. It creates a more solid foundation for future development, such as eliminating redundancies while improving class and function cohesion.
Refactoring also helps address ‘code rot’, where various revisions have resulted in clunky and fragmented code. Making code more efficient, as well as easier to read and maintain, assists with quality assurance and debugging.
Another key benefit of code refactoring is that it assists with keeping technical debt in check. Technical debt is the price that your organisation pays to address problems that have been swept under the carpet or put in the too-hard basket for too long.
If you’re refactoring an application to make the most of the cloud, it often presents a good opportunity to refactor your code as well, in preparation for future business challenges.