I was asked to create a project-layout for our upcoming application using Maven. The first artefact we are going to work on will be the architecture. In order to make it as easy as possible for developers to work I got the idea to separate the actual implementation from the API (like you would do in a OSGi environment).
The dependencies would list the API-project as a dependency for the compile-scope and the implementation is only provided at runtime.
With this approach I am hoping to reduce the complexity for the developers and also restrain them from using internal classes that are frequent subject to change. Furthermore it is possible to hide transitive dependencies (e.g. I dont want the developers to call the DAO-layer from the frontend...this should only be visible from the service-layer).
Has someone put this into practice and how did it go? What do you think about it in general?
Here are some of the main design principles of RESTful APIs using HTTP: REST APIs are designed around resources, which are any kind of object, data, or service that can be accessed by the client. REST APIs use a uniform interface, which helps to decouple the client and service implementations.
A good API must be able to limit the amount of data that can be received in one go, as well as the frequency of requests for data. It should also be able to notify about how many “pages” of the data are left.
REST APIs can use any message format the API developers want to use, including XML, JSON, Atom, RSS, CSV, HTML, and more. Despite the variety of message format options, most REST APIs use JSON (JavaScript Object Notation) as the default message format.
The implementation consisted of moving the code from the JUnit tests into the APIs and then updating the tests to call those APIs. The modifyCertificate method, that provides the implementation for the certificates resource PUT method, was the most complex REST API to implement.
I have seen it a lot, and there are advantages and disadvantages to that approach:
So I think it is nice to publish an API as API only, but it is difficult to develop the API without real source code, and sometimes to implement against the real API without running code that shows how it works.
Different approaches could be:
It's sound design to separate interface (contract) and implementation. But as with everything, use with moderation. You don't want to restrict and complicate the design to the point where it costs more than it delivers. Remember, it's supposed to add benefit (or lower risk), it's not a goal in itself. Ask yourself why you do these things, what the cost and benefit is and what the associated risk and/or cost of NOT doing it would be.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With