[Tutor] Re: Factory classes

Erik Price erikprice@mac.com
Wed, 4 Sep 2002 09:47:23 -0400


On Wednesday, September 4, 2002, at 09:06  AM, Magnus Lycka wrote:

> You can say that factory functions and factory methods extend
> polymorphism to the creation phase of the variable which makes
> use of polymophism. Look at shape above. Where did that variable
> come from? If it can be of several different classes, how did
> that happen?
>
> It might have been passed in as a function or method parameter,

[...]

> The main
> thing here is that the interesting thing where you actually do
> something substantial with your shape isn't littered with a lot
> of irrelevant object creation logic.

Ah, now that makes total sense.  You're right, somewhere along the line 
there had to be code to make the determination of which kind of object 
to instantiate -- in that sense, then Factory classes do exactly that 
(extend polymorphism to include the actual creation of object 
instances).

I've just had one of those "Got it!" moments.


Thanks Magnus!


Erik





--
Erik Price

email: erikprice@mac.com
jabber: erikprice@jabber.org