Le Dimanche, 31 Janvier 2010 15:13:50 -0800,
mer...@stonehenge.com (Randal L. Schwartz) a écrit :

> A class is always a singleton.  There is only one class named Car
> in the system.  However, there can be many car instances, usually
> created by sending "new" to "Car".
> 
> In the Car class, you'd hold information collectively about all cars,
> such as the default specifications or number of cars produced.
> 
> In each car instance, you'd hold information about a specific car,
> like its color or owner.

Thanks for pointing that out.  In the book's example though, the
variable is declared as instance variable.  To go along with class
variables holding information for all instances, it should instead
be declared as class variable isn't it ? (Although it does work like
this).

Object subclass: #CarAssembler
  instanceVariableNames: 'factory'
  classVariableNames: ''

CarAssembler class>>using: aCarFactory
  ^self new factory: aCarFactory

That is, if one thinks that a single car factory should be shared
amongst all instances of CarAssembler.  I think not and I would make it
local to each object instance.

Al
_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to