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


Reply With Quote