Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!goldenapple.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!portc01.blue.aol.com!newsxfer3.itd.umich.edu!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!rill.news.pipex.net!pipex!blackbush.xlink.net!ins.net!heeg.de!uucp
From: Hans-Martin Mosner <hmm@heeg.de>
Subject: Re: counting in smalltalk
Content-Type: text/plain; charset=us-ascii
Message-ID: <3340D852.79E9@heeg.de>
Sender: uucp@heeg.de
Content-Transfer-Encoding: 7bit
Organization: Georg Heeg Objektorientierte Systeme
References: <859822164.1589@dejanews.com> <333FFC1F.3682@smalltalk.com>
Mime-Version: 1.0
Date: Tue, 1 Apr 1997 09:41:38 GMT
X-Mailer: Mozilla 2.01I [de] (WinNT; I)
Lines: 34

Dan Goldman wrote:
> 
> The Customer class should be an abstract description of objects in the
> Customer class.  Assuming that your Customer class describes individual
> customer data, you will have one instance per customer.  So the
> following:
> 
>    Customer allInstances size
> 
> will answer the number of instances of the Customer class.
> 
> ...dan
> 
> olutot06@uwosh.edu wrote:
> >
> > if you have a customer class which stores all customer info and you want
> > to count the number of customers in the customer class, how do you do it?
> > while referencing the customer class
> >
> > -------------------==== Posted via Deja News ====-----------------------
> >       http://www.dejanews.com/     Search, Read, Post to Usenet

Well, you almost certainly don't want to enumerate all instances of Customer.
You should hold a collection of your customers somewhere, add new customers
to it and remove them when they are not customers anymore.
Then you can just ask that collection for its size.
An additional advantage is that you'll be able to handle different customer
collections, for example to maintain the customer sets of different companies
in one Smalltalk image.

allInstances should only be used for debugging purposes, not for the inner
workings of your application.

Hans-Martin
