Data types between Service (Application / Controller) and UI layers

Consider a common layered architecture:

  • interface
  • Service / Application / Controller
  • Domain
  • Persistancy

What should be the types between Service and UI layers?

Should the return types of methods at the service level be primitives ? Can they be domain-level objects ?

Motivation: We are building a forum system. There should be a method like "getForums" somewhere in the service layer. I am wondering what its return type should be -

  • If it is some kind of collection of forumID (primitives) - we will need to issue many more calls to the service layer to represent the topic and description of the forum (using its ID).
  • If it's some kind of collection of Forum objects (from the domain level), we can get a UI that has direct access to the domain level (sounds really bad to me)
  • Should there be a collection of specially crafted objects (representing only the topic, description and forum ID)? (sounds like too much code for nothing)
+1


source to share


1 answer


You can use the data transfer object template:

http://www.martinfowler.com/eaaCatalog/dataTransferObject.html



This will be implemented between the user interface and the service layer and can be adapted to represent the data that the user interface requires.

0


source







All Articles