Dear reader, it’s almost 2025 and in my experience we are connecting more IT systems via interfaces than ever before. Recently I have seen several REST-based interfaces implemented in ABAP to use data from third-party systems in SAP ERP systems.
I have noticed a few negative things about these interfaces that I would like to address in this blog. In addition, I would also like to give some food for thought on how things can be done differently.
What was striking
For some reason, they all had the following characteristics:
- Complete interface in one class
- Class had hundreds, sometimes thousands of lines of code
- No unit tests
- No or poor exception handling
In this blog I would like to address points 1) and 2) in particular. The other points could be the subject of further blogs.
In my view, it’s striking that one class does the work alone. In this context, this is a sure sign that the Single-responsibility principle (SRP) has not been taken into account. As a result, you have problems with the testability and overall maintainability of the interface.
What could be done better
Because an interface should consist of an interaction of different objects (like pretty much everything in an object-oriented world), here’s a simple class list as a starting point for your own work.
Your REST-based interface should have one or more classes to represent the…
- Uniform Resource Identifier (HTTPS access point of the interface, possibly as a value object)
- Connection
- Interface itself
- Request
- Response
- Converter (to read the business data from the response)
- Business data (payload)
- Protocol
- Exceptions (one general interface exception class or better different specialized exception classes)
Summary
The presented list of classes for implementing an interface is a good starting point for your own design.
By having different classes for different tasks (SRP) and loosely coupling those classes, the foundation for testability and maintainability is laid.
Have fun trying it out
Michael