> -----Ursprüngliche Nachricht-----
> Von: Michael Jouravlev [mailto:[EMAIL PROTECTED] 
> Gesendet: Donnerstag, 4. August 2005 23:27
> An: Struts Users Mailing List
> Betreff: Re: DTOs are evil


> So, DTOs are useful where:
> * model was done incorrectly
> * in cases of really severe bandwidth contstraints
> * for sets (lists) of objects
> 

Sorry, but i can't resist replying.

In opposite to the above said, i'd postulate that 
each software system, which is large enough to be of interest (like in
Goedels theorem :-)) , must have DTOs (or ValueObjects)
or it was incorrectly modeled.

Each software system (which is large enough...) has more then one layer.
Different layers usually handles same data. Each of the layers has ist own
view on the data. The business layer, which has to calculate the salary of
an employee is not interested in employee's persistence capabilities. It's
not interested in internal object id (like the one generated by hibernate).
The presentation layer is not interested in employee's identity card
attribute, but solely in presentation issues, like name or similar.
According to the principles of data hiding, a layer should only be able to
access data, which it really needs. Therefore, there is no need that the
employee object which is used by the presentation layer is the same, which
is used by the business layer, and the same which knows everything about
underlying persistence capabilities, like oodb, rdb or file system.

Therefore the DTO object is the protocol, the language spoken between the
layers, and if you want to achieve a layer separation, you need to separate
the view from the data. (Olympic ring metaphor by Ted Husted).

You may say that the DTO's are not OO, because they only contain state and
no behaviour. That's right, but com'on, we are talking about java here, and
java isn't a simple OO language, but a component-oriented language, and DTOs
are part of the component definition.

As for Rod Johnson, he said that DTOs are evil if you don't want to
distribute the application (arguable point btw, because i believe we should
provide clean application design in any case), but as I said before, we are
talking about _LARGE_SYSTEMS and they are 99% distributed.

For a HelloWorld applet, or a small address management programm, I probably
don't need DTOs. As soon, as I have more then one component - I do.


Regards
Leon

P.S. By the way, Rod Johnson also said persistent objects that contain only
getters and setters are evil too (same page as dto, 27). In my understanding
it means hibernate and ibatis which use such objects are at least as evil?
How are you supposed to represent data anyway then?





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to