adaptor pattern with MVC

I'm trying to use the adaptor pattern in a pretty standard way: I have a number of different data models and I implement various adaptors for each model in order to be able to view/edit them. Eg I implement TreeQuestionAdaptor and then I can view my Question objects in my TreeView.

First question: is my naming good/correct? My current naming is XXXYYYAdaptor where YY is what's being adapted and XXX is what it's being adapted to.

My main question is how I should go about creating the adaptors - using new? Using a factory? If I have many views all looking at the same model then should I use the same adaptors for both views or should I have seperate adaptors?

[686 byte] By [alexflinta] at [2007-10-2 5:48:20]
# 1

I went this route recently, but soon refactored into a much simpler design. The problem I found with this approach of wrapping domain objects is that you soon end up with lots of adaptations of the same object, resulting in a lot of duplicate code throughout your adaptors. You could refactor this common code out into a helper but that just adds to a growing list of classes.

An alternative which worked well for me was to reuse the domain objects themselves in the view, and have a view helper handle any awkwardness of dealing with them, (e.g. data convertions) .

Of course I dont know enough about your particular design to suggest this approach, but thought it might interest you as an alternative :o)

rhydthoma at 2007-7-16 1:57:52 > top of Java-index,Other Topics,Patterns & OO Design...