Results 1 to 3 of 3

Thread: In which layer does the model go?

  1. #1
    Join Date
    Apr 2006
    Posts
    9

    Default In which layer does the model go?

    I am creating a test application with Spring and Velocity. It has a separation of layers and implements MVC pattern. In MVC the raw data is kept in the model and i wonder to which layer the model belongs.

    * Is the model part of the presentation layer? If so, the application needs extra code to copy data from the services layer to the presentation layer.
    * Is the model part of the services layer layer? If so, the MVC pattern covers more than one layer.

    Thanks for any comment.
    Pete

  2. #2
    Join Date
    Mar 2005
    Posts
    135

    Default

    Quote Originally Posted by Pete View Post
    I am creating a test application with Spring and Velocity. It has a separation of layers and implements MVC pattern. In MVC the raw data is kept in the model and i wonder to which layer the model belongs.

    * Is the model part of the presentation layer? If so, the application needs extra code to copy data from the services layer to the presentation layer.
    * Is the model part of the services layer layer? If so, the MVC pattern covers more than one layer.

    Thanks for any comment.
    Pete
    The model in MVC is part of the presentation layer. In a lot of cases, these models could be data transfer objects (DTO's) that come in from the service layer with the data containing to display. Spring allows to reuse domain objects in the presentation layer, so that no extra coding is necessary. Just pass in your POJO to your web tier, and you can use that one to present it to the users.

  3. #3

    Default

    Quote Originally Posted by -FoX- View Post
    The model in MVC is part of the presentation layer.
    From a theorical point of view, the MVC is agnostic to wheter you use a layered architecture or something else. Hence in a layered architecture, the VC spread on the presentation layer while the M is made of all the other lower layers. MVC and typical layered architectures are often confused because they share a common goal, decoupling the UI from the business logic.

    Quote Originally Posted by -FoX- View Post
    In a lot of cases, these models could be data transfer objects (DTO's) that come in from the service layer with the data containing to display. Spring allows to reuse domain objects in the presentation layer, so that no extra coding is necessary. Just pass in your POJO to your web tier, and you can use that one to present it to the users.
    What you are talking about here is just how to couple your VC to M, in a layered architecture, the presentation layer to the business logic layer (and transitively the lower ones). Note he could also choose to not use a facade and expose all his domain objects to the presentation layer (although I think it a bad idea). As for your strategy, I agree this is often the best choice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •