Reducing the coupling between our application and the external dependency
In the previous section, although we applied the best practices of consuming external APIs, we created a coupling between our application and that dependency…
Notice that our application actually knows about the data type and structure that is returned by the API. This means that whenever this API changes, we will need to update our code accordingly.
This also means that our application is responsible for handling the different HTTP codes that the API may return. Can’t we abstract this complexity somewhere so that eventual changes are scoped to a small portion of our code?
Of course we can! And there is a pattern for that, which is called Service Agent.
About the Service Agent pattern
The Service Agent pattern abstracts away the details of HTTP communication into a dedicated service, allowing other services (or, in our case, commands) to interact with external systems without directly...