In today’s rapidly evolving technological landscape, modernization is no longer optional. For businesses to remain competitive, they must embrace scalable, maintainable systems while transitioning away from outdated frameworks. At Kloia, we undertook a Proof of Concept (PoC) to explore the capabilities of Amazon Q Developer, a Generative AI-powered tool, in transforming a legacy application. The results were both promising and eye-opening, demonstrating the immense potential of AI in software modernization while highlighting areas where improvement is needed.
Legacy systems, often foundational to business operations, pose challenges in agility and scalability. This PoC focused on transitioning an application from the legacy.NET Framework to a modern stack, specifically.NET 8, while improving maintainability, testability, and overall performance.
Amazon Q Developer’s features—porting, refactoring, explaining, fixing, and optimizing—were tested on key components of the legacy system. Let’s examine the results.
One of the primary objectives was to convert a .NET Framework 4.7.2 library to .NET 8. Amazon Q successfully handled the conversion, ensuring the library could be built and function in the new environment.
However, we found that Amazon Q lacked support for.NET Standard—a critical framework for maintaining compatibility with legacy systems. Modernization projects often require such intermediary steps to facilitate a gradual transition.
Amazon Q handled the transition smoothly but would benefit from broader compatibility options.
The refactoring capabilities of Amazon Q stood out in this PoC. It successfully decomposed complex, monolithic methods into smaller, maintainable units. For instance, a background job responsible for importing files was rewritten with proper separation of concerns.
Code Snippet: Extracted Error Handling Logic
private void HandleError(FileImportParameters jobParameters, Exception exception, LineCounter counter)
{
using (UnitOfWork.Start(UnitOfWorkNestingOption.CreateNewOrNestUnitOfWork))
{
With.Transaction(() =>
{
var header = fileHeaderRepository.Get(jobParameters.FileImportHeaderId);
UpdateHeaderWithError(header, exception, counter);
fileHeaderRepository.Update(header);
});
}
}
private void UpdateHeaderWithError(FileHeader header, Exception exception, LineCounter counter)
{
header.Status = FileHeaderStatusOptions.Failed;
header.Message = "Unexpected error importing file";
header.SystemMessage = FormatErrorMessage(counter.LineNumber, exception);
}
private string FormatErrorMessage(int lineNumber, Exception exception)
{
var message = $"Line {lineNumber}-{exception.Message}-{exception.StackTrace}";
if (exception.InnerException != null)
{
message += $"{Environment.NewLine}{Environment.NewLine}InnerException - {exception.InnerException.Message}-{exception.InnerException.StackTrace}";
}
return message;
}
Generative AI’s ability to explain intricate code was another area where Amazon Q shined. It detailed the logic of a multi-threaded installation function, showcasing how it preserved important contexts like security and logging.
Code Snippet: Multi-Threaded Installation with Contextual Preservation
Parallel.ForEach(apps, (app, loopstate) =>
{
Commons.Threading.With.IOThread(data, culture, principal, log4NetProperties, httpContext,
() => Setup(app, iOAdminEmail, address));
});
Explanation by Amazon Q:
This level of detail made onboarding developers easier and facilitated a better understanding of legacy code.
Amazon Q also demonstrated its capability to identify and resolve inefficiencies. For example, it improved debugging logic by replacing verbose string concatenations with StringBuilder, optimizing resource management.
Code Snippet: Optimized Debugging Logic
catch (Exception ex)
{
logger.Error(ex.Message, ex);
using (UnitOfWork.Start(UnitOfWorkNestingOption.CreateNewOrNestUnitOfWork))
{
With.Transaction(() =>
{
var header = fileHeaderRepository.Get(jobParameters.FileHeaderId);
header.Status = FileHeaderStatusOptions.Failed;
header.SystemMessage = new StringBuilder()
.AppendFormat("Line {0}-{1}-{2}", counter.LineNumber, exception.Message, exception.StackTrace)
.AppendLine()
.AppendFormat("InnerException - {0}-{1}", exception.InnerException?.Message, exception.InnerException?.StackTrace)
.ToString();
fileHeaderRepository.Update(header);
});
}
throw;
}
This reduced memory consumption and improved error reporting.
Lastly, Amazon Q’s optimization feature addressed performance bottlenecks. By introducing better resource management techniques, it ensured smoother execution of file processing tasks.
Code Snippet: Enhanced File Processing Logic
private void ProcessFileRows(
IFileHandler handler,
FileParameters jobParameters,
IFileParser parser,
FileItemBulkInsertRepository itemBulkRepository,
LineCounter counter,
FiletHeader header)
{
var dataTable = itemBulkRepository.CreateEmptyFileItemDataTable();
while (handler.MoveNext())
{
ProcessSingleRow(handler, jobParameters, parser, itemBulkRepository, counter, dataTable);
if (counter.IsBatchFull())
{
SaveAndResetBatch(itemBulkRepository, ref dataTable, counter);
}
}
HandleRemainingRows(itemBulkRepository, dataTable, counter);
Finalize(header, counter, jobParameters, parser);
}
Despite its strengths, the PoC revealed key challenges:
To make Amazon Q more robust for enterprise use:
The PoC with Amazon Q Developer showcased the potential of AI in transforming legacy systems. While it excelled in automating repetitive tasks and offering actionable insights, addressing its limitations will unlock even greater value.
At Kloia, we see tools like Amazon Q as the future of software modernization—empowering businesses to innovate faster and stay competitive in an ever-changing world.
What’s your experience with AI-driven tools in modernization? Share your thoughts below!
Learn more about our modernization strategies at kloia.