Lessons from the Trenches: Using Gen AI for legacy app modernization

Lessons from the Trenches: Using Gen AI for legacy app modernization

Eamonn O’Neill, Co-founder and CTO, Lemongrass, on the value of adopting a Clean Core approach.

There is plenty of talk these days about how gen AI tools can accelerate IT innovation through capabilities like automated code generation. At the same time, there’s a fair amount of concern over the extent to which businesses can safely entrust important work, such as coding, to AI tools.

I’m here to tell you, based on my experiences helping businesses refactor legacy application codebases using gen AI, that AI can be an enabler of massive change in the realm of IT. The caveat, though, is that creating value using AI tools can be hard work. It requires much more than simply asking ChatGPT or Copilot to spit out some code.

To prove the point, allow me to explain how my team is using Gen AI to refactor tens of thousands of lines of legacy application code – and what we’re learning in the process.

My company, Lemongrass, specializes in helping businesses modernize legacy IT estates and moving legacy applications to the cloud.

At present, a key goal of many companies that rely on legacy apps based on the SAP platform is to take advantage of SAP’s Clean Core approach.

Clean Core entails extricating custom code from applications so that it runs as extensions, rather than as a core part of the SAP platform.

This is important because historically, it was a common practice for companies to customize their SAP applications by inserting their own code into them. This made it easy to add special features to the apps. But it also complicated application maintenance and platform upgrades because teams had to ensure that their custom business logic remained compatible with newer versions of SAP’s products – a process that required extensive regression testing and that could prevent successful upgrades in cases where custom code turned out to be incompatible.

By decoupling custom code from applications, the Clean Core initiative aims to make it easier for businesses to keep their core SAP environments consistent and standardized – and, by extension, to help to migrate them to the cloud, where compatibility with standardized environments is critical.

Custom application features will still be available, but through API-integrated microservices hosted on the SAP Business Technology Platform (BTP), which is separate from the SAP “core.”

For businesses with complex SAP estates, the value of adopting a Clean Core approach is clear enough because it makes upgrades and cloud migration much simpler.

What’s much harder for most companies, however, is actually breaking custom code out of their SAP apps and turning it into microservices, due to the sheer volume of code at stake. Many of the businesses I work with have tens of thousands – and in some cases hundreds of thousands – of lines of custom code within their legacy apps. Refactoring all of that code manually would require thousands of days of work by skilled developers. That’s simply beyond the realm of feasibility for businesses whose development teams are already overstretched.

That’s why my team has turned to AI to help companies make the transition to Clean Core. Using Gen AI tools, we are prototyping a solution that analyzes legacy apps to identify custom code within them. From there, it produces a specification document that describes what the custom code does. The document is then reviewed by process owners to confirm that the AI has accurately interpreted the purpose of the custom code. So long as it has, the AI solution goes on to generate microservice code to run on SAP BTP, along with test scripts that can be executed against the new code to ensure smooth upgrades.

The result is the ability to shrink migration projects that would have required thousands of days of tedious legacy app refactoring work into initiatives that organizations can complete in a fraction of that time. And, because our AI solution produces test scripts as well as the microservice code, it ensures that teams can efficiently test their extensions against future platform upgrades, too.

But again, building a solution like this requires much more than simply asking generic AI tools to refactor code.

To ensure that the microservices code produced by our tools actually works as intended, we’re developing an AI module for our Lemongrass Cloud Platform (LCP) tool, which we use in conjunction with third-party foundation models to modernize legacy apps. The custom AI module is a critical part of the equation because we fine-tuned it to adhere to key development and testing standards surrounding SAP applications. As a result, our solution can interpret and rewrite code in contexts where generic AI software development tools, which are not tailored for legacy app modernization, would likely fall short.

We also designed our process to keep a ‘human in the loop’ by requiring manual review of the specification document before AI generates microservices code, as I mentioned. This is important for identifying and addressing situations where our AI tools misinterpret legacy code – which is rare, but which happens, and which could lead to major problems down the line if the resulting microservices failed to work as required.

Going forward, the ability to leverage AI to solve tough challenges like legacy app modernization is poised to become a key differentiator for businesses. Those that can successfully apply AI to such use cases will be in a much stronger position than their competitors to operate efficiently.

That said, AI-driven innovation requires careful planning and customization to produce reliable, high-quality output. It would be nice if AI innovation were as simple as feeding input into publicly available Gen AI services. But my experience shows that some extra steps are required, at least when addressing complex use cases, which require investment in custom AI technology, as well as checks to validate the correctness of AI output.

Click below to share this article

Browse our latest issue

Intelligent CIO North America

View Magazine Archive