Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 725813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:22:49+00:00 2026-05-14T06:22:49+00:00

Hi I am developing an application that needs to work with a complex domain

  • 0

Hi I am developing an application that needs to work with a complex domain model using Hibernate. This application uses Spring MVC and using the domain objects in the presentation layer is very messy so I think I should use DTO’s that go to and from my service layer so that these match what I need in my views. Now lets assume I have a CarLease entity whose properties are not simple java primitives but it’s composed with other entities like Make, Model, etc

    public class CarLease {
        private Make make;
        Private Model model;
        .
        .
        .
    }

most properties are in this fashion and they are selectable using drop down selects on the jsp view, each will post back an ID to the controller.

Now considering some standard use cases: create, edit, display

How would you go about modeling the presentation DTO’s to be used as form backing objects and communication between presentation and service layers??

Would you create a different DTO for each case (create, edit, display), would you make DTO’s for the complex attributes? if so where would you translate the ID to entity?

how and where would you handle validation, DTO/Domain assembly, what would you return from service layer methods? (create, edit, get)

As you can see, I now I will benefit by separating my view from the domain objects (very complex with lots of stuff I don’t need.) but I am having a hard time finding any real world examples and best practices for this. I need some architecture guidance from top to bottom, please keep in mind I will use Spring MVC in case that may leverage on your anwser.

thanks in advance.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:22:49+00:00Added an answer on May 14, 2026 at 6:22 am

    For what it’s worth (I’m developing in C# .net – but the principles should hopefully still be helpful to you) I’ve defined a bunch of types (DTO’s) which I use to exchange data between the business and data tiers; and I have more than one type per domain object / entity. These are defined as simple classes.

    Each of these is built with a specific task in mind, for example:

    • I have a light-weight type designed to populate list views (lots of “rows” but not many “columns”). I also have a corresponding collection type that holds any number of these.
    • I have a “big” get copy which usually has all the properties of the entity in question – but for only one instance of it. I may have more than one of these depending on the size and complexity of the entity vs the cases of use; and also depending on whether you want to return all the data associated with an instance of the entity straight away, or lazy-load some on later requests.
    • I also usually have separate “save” (new) and “update” types for the entity.

    Each type is designed to hold only the information relevant for a given task.
    For example the “big” will return the date last modified, but I don’t expect that in my save and update types because I populate those in the data access layer.

    Also, for my app, these types exist in a common assembly – so they can be re-used between any tier, not just between the business and data tiers.

    Architectural Fit

    There’s nothing particular special about this approach, it has it’s own pros and cons; exactly what those are and how they affect you will depend on a lot of things – I guess your mileage will vary – but it’s certainly served me well for a number of years now.

    People often make a fuss over “separation of concerns” – and that’s a really wise move; this relates to DTO’s in that they are exchanged between layers (and services, components, etc) so there can always some ambiguity over where exactly to draw the line.

    I take the approach that if a bit of information is fit to be exchanged between to tiers it’s probably fit to be exchanged between any number of tiers – so why not make it accessible to all? It also saves have to re-cast information if you’re just passing it through.

    As far as complexity goes – there are two ways of handling that:

    1. Use a verbose / human readable naming convention for all; the types so you know what things are; it doesn’t matter how many there are – that’s what intelli-sense (& docs) are for. The more intuitive the better.
    2. KISS – keep things simple if you can; you’ll have to balance sensible reuse and the Single Responsibility Principle (SRP).

    Would you create a DTO of a complex property of a main entity?

    I’ve found myself making DTO’s for one of 2 reasons:

    1. There’s data I know I need to expose (push), and the design of the DTO is a no-brainer: it’s driven by the data I want to expose.
    2. Pull: the consumer know’s what it wants, and the DTO is designed to meet those needs.

    Because they are all defined in a common assembly no one component “owns” it, it helps force you to think from a ‘domain’ perspective rather than a component centric one; to an extent this will influence the design of the DTO’s (balancing reuse vs SRP).

    In both cases the DTO’s made can be quiet specific to a particular need, or generic; e.g, A DTO that has only a int and a string is not uncommon, it’s the sort of thing you’d use for sending to dropdownlists.

    Most of the DTO collections I send back (from DAL to BL) are specific to a concept – not generic. I enforce very very basic rules on these via the constructors I offer: every arg is required. I’m not sure if this answers your question “How do you manage the assembly and validation”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a .NET application (using C#) that needs to massage some Adobe
I am developing an application that needs to work on Linux, Windows and Mac
I'm developing a C# .NET business application that needs to work on Windows 7,
I am developing an AIR application. This application needs some hardware accesses that are
I am developing a application that needs to store data with many writes and
I'm developing an application that needs to perform some processing on the user's Outlook
I am developing an application that needs to inform users (around 1800) on a
I am developing an application that needs to read back the whole frame from
I'm developing a C++ application that needs a GUI. I would like to use
I am developing an internally-facing application that needs to automatically authenticate users via Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.