That's no excuse to resort to 'instanceof'. there are "other way" to
"tell" if something is a box or circle.
 
$foo.isCircle()
$foo.isSquare()
(well... maybe not...)

#set ($myshape = $foo.getMyShape())
#if ("circle"==$myshape)
 <img src="circle.gif">
#elseif ("square"==$myshape)
 <img src="squar.gif">
#end
 
 
even better?
<img src="$foo.getMyShape()".gif />


I'm not sure instanceof would be easier.
 


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, March 09, 2004 1:54 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Polymorphism (was Re: 'instanceof')
> 
> 
> > -----Original Message-----
> > From: J. B. Rainsberger [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, March 09, 2004 2:45 PM
> > To: Velocity Users List
> > Subject: Polymorphism (was Re: 'instanceof')
> > 
> > Why not just invoke draw() on the Shape and let /it/ figure
> > things out? That's the whole point of polymorphism. If you're
> > just going to ask the object what type it is, then decide what
> > to do with it as a result, then why have polymorphism at all?
> 
> I'm talking about from the template point of view. If you are 
> using velocity to display some object (ie. text/html) and the 
> object you are displaying has a 'Shape', why is it so bad for 
> your template to display a box/circle if you can tell that 
> the Shape is a box/circle? 
> 
> The Shape may know how to draw itself form an AWT point of 
> view, but that doesn't apply for text/html.
> 
> Michael
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to