
Internal Data Transfer Objects - Anon84
http://fragmental.tw/2008/12/22/internal-data-transfer-objects/
======
russell
Another rant. :-) I think the pattern is sufficiently broken that it is an
anti-pattern. Look at the Sun definition
<http://java.sun.com/blueprints/patterns/MVC-detailed.html>. It tries to
encompass J2EE and swing. What happens is the pattern gives no good guidance
to a programmer. The pet store example is even worse because it gets tangled
up in EJBs. My personal pattern is to write the model as a POJO (Plain Old
Java Object, no framework cruft) so I can write simple unit tests and to
package the result as a HashMap. The view part is also very simple, variables,
loops, and ifs, no calculations, no Struts goodies. Life is so much simpler.

------
russell
Worth reading. DTOs are an example of class myopia that is all too present in
the Java world. really, you don't need to invent a class for a bunch of data.
The DTO doesn't do anything except pass a bunch from one component to another.
It doesn't have any inherent functionality. Worse yet, it is a tight coupling
between the the components in an MVC pattern. If you change the model, you are
forced to change the DTO. If uou delete a field from the DTO, you have
probably broken the view. It is much better to use a HashMap or JSON as a data
transfer. It's much less fragile.

