Hexagonal architecture (Ports and Adapters) is a design pattern that aims to build extensible, maintainable applications by clearly separating business logic from technical details and external dependencies.
This pattern translates naturally to the Progress OpenEdge ABL language, bringing the same benefits (maintainability and the ability to evolve), and showing once again how well this platform adapts to current needs.
01Core Principle
The central idea of hexagonal architecture is to place the business domain at the heart of the application, and to surround that business logic with interfaces and adapters that connect the application to external technologies (such as databases, file systems, external APIs, etc.).
02Components of Hexagonal Architecture
Domain (Core Domain)
- Entities: represent business objects with their properties and methods.
- Value Objects: represent immutable objects, often used for complex data types.
- Domain Services: contain business logic that cannot easily be placed in entities.
Application
- Use Cases: define the specific actions the application can perform. They orchestrate calls to the domain and manage transactions.
- Ports (Interfaces): definitions of the interfaces that adapters must implement. They connect the domain to external systems.
Ports
- Primary Ports (Driving Ports): interfaces defining the services the application exposes to its users (for example, REST APIs or user interfaces).
- Secondary Ports (Driven Ports): interfaces defining the external services the application uses (for example, databases or external services).
Adapters
- Primary Adapters (Driving Adapters): concrete implementations of the primary ports. They handle interactions with users (such as REST API controllers or user interfaces).
- Secondary Adapters (Driven Adapters): concrete implementations of the secondary ports. They handle interactions with external systems (such as database repositories or external API services).
03Workflow
- User interaction: users interact with the application through primary adapters (for example, by sending an HTTP request to a REST API).
- Use case call: the primary adapter invokes a specific use case in the application layer.
- Business logic: the use case calls the domain services and entities to execute the required business logic.
- Interaction with external systems: where needed, the use case calls secondary ports to interact with external systems through secondary adapters.
- Result: the use case returns the result to the primary adapter, which formats it and sends it back to the user.
04Benefits
- Technology independence: technical dependencies and business logic are clearly separated, so you can switch technologies without affecting the domain.
- Testability: business logic can be tested in isolation, using test doubles (mocks or stubs) for the ports.
- Extensibility: new adapters can be added without changing the business logic.
- Maintainability: separation of concerns makes the code cleaner and easier to maintain.
05Hexagonal Architecture Diagram

06ABL Code Example (OpenEdge)
Domain (business logic)
File: Customer.cls
CLASS Customer: DEFINE PRIVATE VARIABLE customerId AS CHARACTER NO-UNDO. DEFINE PRIVATE VARIABLE name AS CHARACTER NO-UNDO. DEFINE PRIVATE VARIABLE email AS CHARACTER NO-UNDO. CONSTRUCTOR PUBLIC Customer (cid AS CHARACTER, cname AS CHARACTER, cemail AS CHARACTER): sc-camel-customer-id = cid. name = cname. email = cemail. END CONSTRUCTOR. METHOD PUBLIC CHARACTER getCustomerId(): RETURN customerId. END METHOD. METHOD PUBLIC CHARACTER getName(): RETURN name. END METHOD. METHOD PUBLIC CHARACTER getEmail(): RETURN email. END METHOD. END CLASS.
Application (use cases) and Ports (interfaces)
File: CustomerService.cls
USING Progress.Lang.*. INTERFACE CustomerRepository: METHOD PUBLIC VOID addCustomer(INPUT customer AS Customer). METHOD PUBLIC Customer getCustomerById(INPUT customerId AS CHARACTER). END INTERFACE. CLASS CustomerService: DEFINE PRIVATE VARIABLE repository AS CustomerRepository NO-UNDO. CONSTRUCTOR PUBLIC CustomerService(INPUT repo AS CustomerRepository): repository = repo. END CONSTRUCTOR. METHOD PUBLIC VOID registerCustomer (customerId AS CHARACTER, name AS CHARACTER, email AS CHARACTER): DEFINE VARIABLE customer AS Customer NO-UNDO. customer = NEW Customer(customerId, name, email). repository:addCustomer(customer). END METHOD. METHOD PUBLIC Customer findCustomerById(INPUT customerId AS CHARACTER): RETURN repository:getCustomerById(customerId). END METHOD. END CLASS.
Adapters (concrete implementations)
File: CustomerRepositoryImpl.cls
USING Progress.Lang.*. CLASS CustomerRepositoryImpl IMPLEMENTS CustomerRepository: DEFINE PRIVATE TEMP-TABLE ttCustomer NO-UNDO FIELD customerId AS CHARACTER FIELD name AS CHARACTER FIELD email AS CHARACTER. METHOD PUBLIC VOID addCustomer(INPUT customer AS Customer): CREATE ttCustomer. ASSIGN ttCustomer.customerId = customer:getCustomerId() ttCustomer.name = customer:getName() ttCustomer.email = customer:getEmail(). END METHOD. METHOD PUBLIC Customer getCustomerById(INPUT customerId AS CHARACTER): FIND FIRST ttCustomer WHERE ttCustomer.customerId = customerId NO-LOCK NO-ERROR. IF AVAILABLE ttCustomer THEN RETURN NEW Customer(ttCustomer.customerId, ttCustomer.name, ttCustomer.email). ELSE RETURN ?. END METHOD. END CLASS.
Usage
File: Main.p
USING CustomerService.
USING CustomerRepositoryImpl. DEFINE VARIABLE repository AS CustomerRepositoryImpl NO-UNDO.
DEFINE VARIABLE service AS CustomerService NO-UNDO. repository = NEW CustomerRepositoryImpl().
service = NEW CustomerService(repository). service:registerCustomer("1", "John Doe", "john.doe@example.com").
MESSAGE service:findCustomerById("1"):getName().
This structure keeps a clear separation between business logic and implementation details, making the code more modular and easier to test.
07UML Representation
Class Diagram
This diagram shows the relationships between the classes in our architecture.

Use Case Diagram
This diagram shows the main interactions between the user and the system.

Sequence Diagram
This diagram shows the order of calls between objects for a given scenario, such as registering a customer.

08Conclusion
Whether or not you work with Progress OpenEdge, hexagonal architecture lets you build robust, scalable applications by clearly separating business logic from technical details. The code becomes easier to maintain and test, with greater flexibility when technologies change.
This is especially valuable for business software publishers whose business rules are maintained over several decades.
Quadza Software can support your teams over the long term as they adopt this approach.
Patrick


