I'm trying to get more acquainted with rest and try to understand what layered system means in REST architecture. As far as i understand it means that if API has database it should be on different machine on different server and api call it when it is needed. The same with bussines logic, if call should be passed through some logic call is transfered to some other server and executed there. This also will help to solve performance issue if it exist. Am I right? please give any additional info
Well, I wouldn't think of a layered system as "each layer has to reside in a separate server'. It is more about the separation of concerns, i.e. every layer should have a single high-level purpose and deal only with that. I will try to explain better with an example of what is wrong :
@GET
public String myService() {
return "<html><body><div>HELLO</div></body></html>";
}
Here you have the service and presentation layer all mixed up. Instead, the service should just return "HELLO", while the client (which I assume here is a presentation layer) should be able to decide how to present the data. One of the most common architectures is the so-called 3-tier architecture, where you have data access, business logic and presentation. Services could be added as a separate layer, most commonly between business logic and presentation (so that you can apply the same business logic to different clients, e.g. web and mobile).
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