Question

We are developing an 3-tier application where presentation layer communicates with service layer, which in turn communicates with the business layer. The business layer has access to database. Currently we have implemented business layer to hold CRUD operations for tables. We have a couple of doubts regarding organizing the methods in service layer and business layer.

  • Firstly, how should the methods at service layer be grouped? Should we group the methods based on a page basis, where in all the data a page needs are provided by a method of a service. Or should we fetch the page data by multiple service calls ?

  • The other concern is about organizing methods at the business layer, it seems that for any method at the service layer we have to implement a corresponding method at business layer. If we go by this logic the methods at service layer would be acting like dummies, and only taking care of authorization and validation. For ex: when fetching a data that comes from join of two table, should we fetch the two tables on the service layer and then do the join on the service layer or should we have a function on business layer which does the same thing. Essentially reducing the data transfer between service layer and business layer.

Was it helpful?

Solution 2

Well it looks like what i wanted was to follow the REST architecture. Which means that i should keep the interfaces uniforms between service layer and presentation layer. The service layer takes care of authorization and just delegates all the calls to the business layer. At business layer we keep the DTOs which are serialized to XML, JSON or whatever before sending them to SL. What really helped me was going through REST articles and exploring them in detail.

OTHER TIPS

Please have a look at the DTO pattern. With the DTO pattern - you minimize the number of calls to the backend service. And given DTO can map in to multiple BOs. You need to design DTOs based on your data requirement to populate the UI.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top