--- In [email protected], "Jonathon Stierman" <[EMAIL PROTECTED]> 
wrote:
>
> I would say it's more flexible to use the ClassFactory because you 
can
> dynamically set the properties in the ClassFactory.  Simple example:
> 
>  
> 
> Say you had an application that creates Squares - just simple 
rectangles
> on the screen.  When the user presses a button, a new square pops 
up in
> a random location.  If you used a hard-coded class to fill your 
Square
> class with pre-set instance data, you're locked in to your
> implementation.  You'll have to write a new class if you wanted to 
give
> the user the option to create a RedSquare instead of a Square.  It 
gets
> exponentially difficult if you have multiple things that might need 
to
> change as well: say color, size, border-thickness, etc.  You'd have 
to
> make a new class (and then configure your application to use that 
new
> class!) for each property of Square.  Not pretty!

...

Also, when you're using a class as an ItemRenderer for a List based 
component, you don't have the luxury (AFAIK) of passing any 
properties to its constructor.  So you can use a ClassFactory to set 
those properties in advance, then use the ClassFactory as the 
ItemRenderer.

http://tinyurl.com/56hngy

HTH;

A

Reply via email to