Results 1 to 3 of 3

Thread: Binding to business domain objects

  1. #1
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default Binding to business domain objects

    Is it ever a good idea to bind directly to business domain objects?

    My answer so far: NO, except for trivial cases where you have a domain object with no associations to other domain objects, so a domain object with just value (Strings, ...) properties.

    With the bad rep that DTOs have gotten lately (and I agree, they are not true objects!) I was doing my best to bind directly to the domain objects in a Spring/Hibernate web app. However, I kept running into all kinds of problems (e.g. side effects because of business logic in setters during data binding...), most of which can be solved by binding to dummy DTOs and having your business facades process those DTOs and invoke the required domain object methods.

    Am I missing something here or are DTOs just a necessary evil?

    Erwin

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney
    Posts
    503

    Default

    We bind to domain objects whenever we can to save time/effort.

    This is pretty subjective, but if you're building a page where most of the domain object fields appear on that page, there's nothing to gain by building an intermediate DTO type object.

    You can also of course plug in property editors to easily handle non-String properties.

    Some purists might disagree, but practically speaking, who cares. i.e. DTOs are just evil, not a necessary evil.

  3. #3
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    Ofcourse I'm not saying that you should have DTO in all cases, especially when you're just displaying data. In that case there are no issues with just pulling the data directly out of the domain objects.

    We bind to domain objects whenever we can to save time/effort.
    I agree, there are cases where it will work. But it seems to brake down in most non-trivial cases when your setters have complex logic in them, especially with bidirectional association between domain objects.

    As you say, for simple unidirectional associations you might also be able to cope by just registering the required property editor.

    Here is a very interesting discussion that also mentions these kinds of issues, some of which also relate to the open-session-in-view pattern:
    http://www.newsarch.com/archive/mail.../msg03641.html

    Erwin

Similar Threads

  1. Replies: 1
    Last Post: Jun 24th, 2007, 10:58 AM
  2. Spring-based architectural approach
    By diegum in forum Architecture
    Replies: 9
    Last Post: May 10th, 2007, 04:09 PM
  3. Replies: 2
    Last Post: Oct 10th, 2005, 05:12 PM
  4. Replies: 0
    Last Post: Jan 6th, 2005, 08:19 AM
  5. Should Business Objects have References to DAOs?
    By sethladd in forum Architecture
    Replies: 9
    Last Post: Aug 25th, 2004, 01:18 PM

Posting Permissions

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