velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Barbara Baughman <>
Subject RE: 'instanceof'
Date Mon, 08 Mar 2004 22:16:10 GMT
I would assume that each "Shape" class could have a public getType
method which would return Circle, Square, etc.  Then you could use
$shape.type in the Velocity context to output depending on the shape
type.  The idea is not to force your designer to wear a programmer hat
in order to work with the information you supply in the context.
When designing classes to send to your designer in the context, keep
in mind these "courtesy" methods that can make like so much easier.

Barbara Baughman

On Mon, 8 Mar 2004 wrote:

> > Somewhere you want to use an instanceof check. In general, a
> > performs an instanceof check in an 'if' statement of some kind.
> > So apply Replace Conditional with Polymorphism [Refactoring],
> > which generally introduces a Strategy [GoF:Design Patterns] into
> > the design. Of course, I'm just guessing, but it's a pretty good
> > bet.
> How would you test for specific instances of a polymorphic class in the
> view? If the view gets a Shape, no reason why the view can't test for
> Circle, Square, or ? to display a specific thing for the viewer...
> Well, it can't if there is no 'instanceof' at the view... ;}
> Michael
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message