http://en.wikipedia.org/wiki/Visitor_pattern
--- On Wed, 11/26/08, BJ Freeman <[EMAIL PROTECTED]> wrote: > From: BJ Freeman <[EMAIL PROTECTED]> > Subject: Re: Discussion: Screen Widget Java Code Cleanup > To: dev@ofbiz.apache.org > Date: Wednesday, November 26, 2008, 6:50 PM > where can I find out about the visitor model > > Adrian Crum sent the following on 11/26/2008 6:05 PM: > > I would like to work on cleaning up the screen widget > Java code. Here are some of my ideas: > > > > 1. The screen widget model classes are trying to be > too many things. As a result, they contain some messy and > scary code. I'd like to see the model widget become more > of a data structure, and move the rendering code into the > rendering classes. > > > > 2. Use a true visitor pattern in the model widgets. > The current pattern is what I would call "befuddled > double dispatch with baggage." Methods like > > > > public void renderWidgetString(Appendable writer, > Map<String, Object> context, ScreenStringRenderer > screenStringRenderer) > > > > would become > > > > public void accept(ScreenWidgetVisitor visitor). > > > > Rendering classes would implement the > ScreenWidgetVisitor interface. The model widgets won't > need to be concerned with writers, contexts, or any other > messy details. > > > > 3. Convert the existing artifact gathering code to a > screen widget visitor. That would get the artifact gathering > code out of the model widgets and put it where it belongs. > It would probably simplify the artifact gathering code as > well. > > > > Once these steps are completed, the model widget > classes will be simple immutable data structures. The only > code most of the model classes will have is a constructor > and the accept method. > > > > The rendering code will be simplified, since there > will be better separation of concerns. > > > > I will probably start off with #1 - move the rendering > code from the model classes to the rendering classes. Once > the dust settles from that, I will introduce the visitor > interfaces and visitor classes. The existing model methods > will be deprecated. The model classes will be bloated while > they support both patterns. When the time is right we can > remove the deprecated methods and we'll have lean, well > structured screen widget code. > > > > What do you think? > > > > -Adrian > > > > > > > > > > > >