- Persistence objects, which can closely mirror the database schema if necessary and guarantee that "transparent" ORM stays that way.
- Business/Domain objects, which reflect the application's core entities and the business logic that manipulates them.
- View objects, which are data objects optimized to serve the View layer.
- Message objects, which are exposed to the outside world via services and need to remain stable in the face of changes to the business layer.
In anything other than a trivial application and given current technologies, it is very difficult to use a single object model to serve all of the needs described above. (Trust me, I've tried.) So in reality, we spend a lot of time in the transfer implementation, moving values back and forth between the different flavors of objects, either with tedious set/get code, a hand-rolled reflection-based framework, or (more likely) a combination of both.
Clearly this is annoying. So I was excited today when one of my friends told me about Dozer, which purports to be a "powerful, yet simple Java Bean to Java Bean mapper". I haven't tried it yet -- just spent a lot of time going through the documentation. But it appears that Dozer will allow me to wire up hierarchies like those I describe above in a minimal-code, declarative fashion. I'm looking forward to trying it out and reporting my experiences.
No comments:
Post a Comment