Migration & Modernization

AWS Blu Age Code Maintainability

In this blog post, we outline the criteria for evaluating code maintainability and explain how AWS Blu Age transforms mainframe applications into maintainable object-oriented Java.

AWS Blu Age allows customers to transform mainframe applications into Java Spring. This transformation not only remediates technology concerns, but enables business transformation. Without Java applications that can be readily picked up by new programmers, modernization efforts falter, leaving most postmodernization work focused on maintenance.

When evaluating COBOL to Java or similar refactoring services, terms like JOBOL often appear. The term JOBOL refers to Java code that mimics COBOL’s structure, often reflecting a lack of understanding of the original code’s logic. AWS Blu Age generates code that avoids JOBOL through model-to-model transformations, reusable classes, and non-procedural patterns, creating a cleaner, modern, and maintainable implementation.

Readability

The code should be straightforward to read and understand, with clear naming conventions and meaningful comments explaining the code’s purpose and logic. Consistent coding style throughout the project reduces cognitive load for developers and makes the codebase easier to navigate.

The AWS Blu Age Transformation Engine generates readable and understandable code following a consistent coding style and Java project structure.

The AWS Blu Age modernized application is packaged as Java web applications (WAR), that you can deploy on any Java Enterprise Edition server. Typically, the server is a Tomcat instance that embeds the AWS Blu Age Runtime, which is built upon Spring Boot and Angular frameworks.

The basic Java projects organization relies on the following structure:

  • Entities project – contains business model and context elements. The project name generally ends with “-entities”. Typically, for a given legacy COBOL program, this corresponds to the modernization of the I/O section (data sets) and the data division. You can have more than one entity project.
  • Service project – contains the legacy business logic modernization elements. Typically, this is the procedure division of a COBOL program. You can have more than one service project.
  • Utility project – contains shared common tools and utilities used by other projects.
  • Web project – contains the modernization of UI-related elements, as applicable. These UI elements could come from CICS BMS maps, IMS MFS components, and other mainframe UI sources. You can have more than one web project.

For clear traceability, each Java class maintains the name of its corresponding COBOL program. During refactoring, the AWS Blu Age Transformation Engine applies customer-specific naming conventions for variables and functions. The project leverages Apache Maven for build automation and project management, ensuring consistent structure and centralized dependency management.

Modularity

Code should be organized into distinct modules, classes, or functions that each handle a specific aspect of the system. This modular approach enables updates to individual components without affecting the entire system and allows for component reuse, reducing duplication and improving maintainability.

AWS Blu Age generates code organized into multiple layers, adhering to Object-Oriented design best practices, unlike COBOL’s monolithic structure. This organization includes the following:

  • The COBOL data division is transformed into multiple entities (one per 01/77 level COBOL data structure). A context class is generated, grouping all entities into a single Java object that reproduces the run unit context concept of COBOL. It can be serialized/de-serialized when the context has to be restored on a new invocation of the program.
  • Each program has its own configuration class that allows custom behavior to be specified on a program basis. For example, it is possible within one application to have a program processing ASCII data, and another program processing EBCDIC data.
  • The COBOL procedure division is converted into a Service class implementing an interface, aligning with the dependency injection framework used in modern applications like Spring. COBOL paragraphs become standard Java methods.
  • Finally, a class with the name of the program makes the link between all those different classes. This class exposes a run method that, when invoked, runs the modern version of the program.

This architecture merges identical data structures into a single class, reducing code duplication, and simplifying maintenance.

Complexity

The complexity of the code is mainly measured through the cyclomatic complexity and code duplication.

  • Cyclomatic complexity – This measures the number of independent paths through the code. Lower complexity generally indicates that the code requires minimal effort to understand, test, and maintain. High complexity can make the code more prone to bugs and harder to modify.
  • Code duplication – Repeated code should be minimized. Duplication increases the maintenance burden, as changes need to be propagated across multiple locations. Refactoring duplicated code into functions or classes can improve maintainability.

The modernized code inherits some of the complexity of the legacy system. Despite this, the code is more straightforward to read and navigate than COBOL. It’s due to clearer method navigation, indentation, and syntax. For example, braces for if/else statements compared with COBOL’s END-IF and dot mechanisms.

The code follows all standard Java Spring coding rules that allow any Java developer to quickly dive into the code.

  • Multiple tiers, each one focused on a specific architecture layer.
  • Objects with standard getters/setters.
  • Interface/Implementation Spring pattern.
  • Fluent-APIs backed framework.
  • Isolation of configuration aspects in dedicated artifacts allowing quick access and modification if needed. For example, SQL queries in dedicated files and YML configuration.

Complex control-flow algorithms are used during the transformation to understand how each program behaves. The AWS Blu Age toolchain uses code execution simulations to find the possible execution paths so that the modern code deals only with what is required. This process maintains the legacy structure by converting COBOL paragraphs into Java methods while preserving the behavior of COBOL’s “GO TO” constructs.

Evolvability

The code should be designed to accommodate changes with minimal effort. Components should be loosely coupled, meaning that changes in one part of the system should have minimal impact on others.

With postmodernization, all of the features from modern languages are now available and can be readily activated in the modern application.

The entities used (originating from COBOL data structures) are JSON compatible, allowing programs to be exposed using a modern HTTP endpoint with JSON payloads in few minutes, leveraging Spring capabilities and annotations. Consequently, the application’s source code can be seamlessly integrated with API-based solutions, messaging systems, and other modern technologies.

The generated code is homogeneous and follows the same patterns everywhere. The following are examples of common changes that can be readily implemented.

  • A new specific behavior has to be implemented globally. Implement it across the whole application using Aspect-Oriented Programming (AOP), powered by AspectJ through Spring.
  • A data-access routine should behave differently in production (real data) and test (stubbed data). Because the code uses Java interfaces, create your test implementation and configure Spring to use different beans based on the profile (production/test).
  • An infinite loop program is used to listen and answer IBM MQ messages. Refactor the code to use Spring Integration for message handling, enabling a scalable listener that processes messages in parallel based on traffic, replacing the legacy sequential handling.
  • A need to improve the execution time of an existing batch. Add parallelization using Spring task-executor concepts along with Java Future objects by directly wrapping existing code in a Java Runnable.

The Java code created with AWS Blu Age is standard Java code, following modern code best practices. This allows the code to be further evolved after migration to reduce complexity and improve maintainability, like any standard Java project.

Code Reviews and Quality Assurance

Static analysis tools like SonarQube ensure code quality and maintainability by detecting errors, security vulnerabilities, and coding standard violations.

AWS Blu Age uses SonarQube, a static code analysis tool, as a key performance indicator for code quality. SonarQube scans the codebase without executing it, identifying bugs, security vulnerabilities, and potential performance issues early in the development process. It enforces standards through “Quality Gates” by setting thresholds for critical metrics like bugs, test coverage, and code complexity.

Key features of SonarQube in AWS Blu Age:

  • Provides insights into code duplication and maintainability issues.
  • Detects security vulnerabilities using standards like OWASP Top 10.
  • Identifies code smells, indicating poor practices or design.
  • Allows customization of rules and thresholds to meet specific project requirements.

AWS Blu Age ensures the modernized code receives an AAAA rating from SonarQube using the customer’s SonarQube profile, guaranteeing high-quality, maintainable code that meets industry standards.

Documentation

Two types of documentation can be considered:

  • Inline Documentation – Comments within the code that explain complex logic, algorithms, or non-obvious decisions are essential. Comments should not be redundant or explain self-explanatory code.
  • External Documentation – Comprehensive documentation, including API references, architecture diagrams, and usage guides, helps new developers understand the system and contribute effectively.

For inline documentation, the AWS Blu Age transformation process maintains all of the comments within the code that explain the logic.

Javadoc, included with the JDK, can be used to enforce a consistent style of documentation that can be followed and understood by other developers. By generating web-based HTML documentation, it makes it simpler for developers to browse and search through the codebase’s documentation. It helps in maintaining code by ensuring that each piece of functionality is well-documented, making it understandable for future development and debugging efforts.

Testability

Code should be written in a way that makes it straightforward to test individual components with unit tests. This often requires designing code with loose coupling and clear interfaces. Comprehensive automated tests, including unit, integration, and regression, ensure code changes don’t introduce bugs, simplifying maintenance.

The refactored code has clear interfaces and loose coupling, facilitating unit test generation. Tools like JUnit, EvoSuite, and JUnit-Quickcheck can automatically generate unit test cases based on the code, and tools like JaCoCo can be used to analyze code coverage by tests and identify areas requiring additional test cases.

AWS offers AWS Mainframe Modernization Application Testing, a service for recording, replaying, and comparing application tests at scale. It enables creating testing workflows with high automation for test replay, comparison, and validation of application functionality.

Conclusion

AWS Blu Age increases the agility of mainframe applications, and takes customers through an evolution from the mainframe monolith to agile macro services. It enables customers to adopt a modern development environment that boosts productivity, removes blockers, and allows flexible, independent development and testing. The result is reduced time to market, reduced cost of change, and remediation of the risk of retiring legacy skilled resources. You can continue the next phase of modernization by introducing microservices, leveraging AI for mainframe applications, and integrating with AWS cloud services.

Additional AWS Blu Age resources: