| Author |
Use of adapter pattern to decouple
|
John Molitor
Ranch Hand
Joined: Nov 08, 2004
Posts: 39
|
|
I am looking at using object adapters to decouple my domain model from my presentation tier. Our initial strategy was to take the domain objects, and convert those to DTO's that would be used by the jsp servlets to build the pages. I was thinking about creating adapters that would have the domain object as a constructor argument and attribute, and the getters would access the values from the domain object to build the page. I believe this would require serialization of the argument domain object (and associated objects), which could be costly?. The way I see it I have three possible approaches: 1. Go with the adapter pattern, and potentially serialize a lot of objects, 2. Have DTO's that take a domain object as a parameter, then load the attributes of the DTO, or 3. Create a "factory" that builds the DTO's? Any input would be greatly appreciated. Thanks.
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
I usually figure DTOs are a necessary evil, used only when imposed by inter-component protocols in some architectures. Which makes the architecture at least malevolent if not evil. If you can avoid them, do so. What's wrong with the presentation layer knowing about the domain model? Sounds perfectly natural. Traditional MVC and its ilk all make sure that the domain model is not aware of the presentation layer. That's usually the important bit. I could make up a requirement that would lead us to an adapter, but it would be pretty unusual. Are you sure you have one?
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
Are your domain model and the presentation tier running in different VMs? If not, I agree with Stan - I wouldn't see a problem with the presentation tier working directly on the domain model.
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
 |
|
|
subject: Use of adapter pattern to decouple
|
|
|