Harmeet,

That is exactly what I was trying to describe. The idea behind screen widgets 
is to have them "rendering format agnostic" - and the visitor pattern is 
perfect for that.

-Adrian


--- On Wed, 11/26/08, Harmeet Bedi <[EMAIL PROTECTED]> wrote:

> From: Harmeet Bedi <[EMAIL PROTECTED]>
> Subject: Re: Discussion: Screen Widget Java Code Cleanup
> To: dev@ofbiz.apache.org
> Date: Wednesday, November 26, 2008, 11:51 PM
> My understand is that the value of visitor is: have simple
> data structures and code/attach what is done on the data
> structure using visitors.
> 
> This may seem odd given that one should have operations
> close to data structure but it turns out very useful esp. if
> there are classes of operations done on number of data
> structures. Each class of operations becomes one visitor,
> making operation addition easier.
> 
> So as an example - take 2 classes of operations - render to
> html to render to pdf on same set of data structures X, Y,
> Z.
> In visitor world one would write two visitors and make X,Y,
> Z visitable(i.e. have accept method)
> If methods were close to datastructures, one would write 2
> types of rendering within class representing X,Y,Z
> 
> Having one visitor per rendering has the benefit that all
> the rendering code is in one visitor implementaion. This
> makes it easy to refactor/reuse. I have seen code get
> cleaned up a lot when using visitors.
> 
> I am not sure how this would apply to ofbiz code.. but it
> seems that proposal intent is to take things like
> Appendable writer,  ScreenStringRenderer
> screenStringRenderer out of widget/screen code.
> Visitor will have these and access to datastructure (on
> acceptance of visitor by visitable class e.g.
> ModelScreenWidget) and will do right string appending.
> 
> hope this was useful.
> 
> harmeet


      

Reply via email to