Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!portc02.blue.aol.com!howland.erols.net!blackbush.xlink.net!ins.net!heeg.de!hmm
From: hmm@heeg.de (Hans-Martin Mosner)
Subject: Re: dynamic class variable?
Message-ID: <E1255y.J42@heeg.de>
Sender: uucp@heeg.de
Organization: Georg Heeg Objektorientierte Systeme, Dortmund, FRG
X-Newsreader: TIN [version 1.2 PL2]
References: <328CDFE3.435E@corona.mitre.org>
Date: Mon, 18 Nov 1996 08:34:46 GMT
Lines: 32

Annette S. Riffe (asr@corona.mitre.org) wrote:
: I have a list that I would like to make a class variable.  The list
: is read from disk, though, so it can have different contents every time
: I run my program.

: Is the correct way to do this to put "ClassName initialize" somewhere
: in my program?  Is there another way to do this, maybe not using a
: class variable?

: -ASR

There are 2 general ways to approach this:

1. If you know that your application will only be run once in an image,
you should implement a method #initializeClassVarFromFile: or similar
in the class holding the class variable. When your application starts up,
it should execute this method to get the contents of the file.
The #initialize method of the class is normally used for one-time
initialization only, such as defining manifest constants for some algorithm.

2. If your application might be run several times in parallel in an image,
you should make that class var and inst var, so that every instance of the
application can have its own copy of the list. You don't write in what
Smalltalk dialect you work; in VisualWorks, a variable in your ApplicationModel
subclass would be most appropriate.

Hans-Martin
--
+--- Hans-Martin Mosner ---- Senior Smalltalk Guru :-) ---+
| These opinions are entirely ficticious.  Any similarity |
| to real opinions is purely coincidental and unintended. |
+--- <hmm@heeg.de> ------ URL:http://www.heeg.de/~hmm/ ---+
