Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!bellcore!spectral!sjs From: sjs@spectral.ctt.bellcore.com (Stan Switzer) Newsgroups: comp.windows.news Subject: Re: Class vars or Instance vars Message-ID: <14719@bellcore.bellcore.com> Date: 14 Mar 89 15:10:12 GMT References: <101*knut-skog@rglab.uit.uninett> Sender: news@bellcore.bellcore.com Reply-To: sjs@ctt.bellcore.com.UUCP (Stan Switzer) Organization: Bellcore Lines: 49 In article <101*knut-skog@rglab.uit.uninett> knut-skog%rglab.uit.uninett@NORUNIX.BITNET (Knut Skog) writes: > .... In object oriented system design > a class should be constructed based on the true nature of the attributes > of the objects under consideration. Class variations should be taken care > of by subclassing and truly private data of a class instance should be > defined as instance vars. The fact that class-vars is 'turned into > instance vars' (placed in Instance dict) as soon as their attributs are > assigned dynamicaly and therby makes it preferable to write 'natural > instance attributes' as class-vars, is a pecullarity of this system that > class-writers must be aware of. Right? This is indeed true (so long as you use "def" and not "store" to change the values). It is an interesting and useful feature of NeWS's class system that default values for instance variables can simply be declared as class variables. Generally, with variables that reflect user preferences, etc., and which don't change too much (i.e. aren't *really* part of the object's dynamic state) I make them class variables with the understanding that they can be overridden by assigning to the instance. Additionally, such variables can be overridden in subclasses. Although this feature is somewhat unusual it is not unique to NeWS. The language "Self" described in the '87 (I think) OOPSLA has the same property. In a "true" object-oriented system, ALL data would be objects. In this case, the distinction between shared and non-shared object usually remains. Generally, composite objects are shared and simple objects (in SmallTalk, just the small ints) are not. (The point is somewhat moot since there are no operations that *change* atomic objects, only operations that create new immutable objects, so you really wouldn't know if they were shared or not.) In any system with class variables (or other means of namespace sharing) one must distinguish between shared objects and shared references to objects. > > In my 25-years as computer professional I have never had a more > enjoyable and interesting experiance than NeWS. Likewise. I haven't had as much enjoyment programming since I first got my hands on LISP 1.5. In the elegance of its conception and the virtuosity of its execution NeWS is nearly unparalleled. Stan Switzer sjs@ctt.bellcore.com "NeWS -- The windowing system for the other half of your brain." -- Don Hopkins