Path: utzoo!mnetor!uunet!tektronix!tekcrl!jans From: jans@tekcrl.TEK.COM (Jan Steinman) Newsgroups: comp.lang.smalltalk Subject: Re: Object Orientation and The Truth Message-ID: <2343@tekcrl.TEK.COM> Date: 23 Feb 88 18:06:17 GMT Organization: Tektronix Inc., Beaverton, Or. Lines: 46 (Quoted sections from johnson@uiucdcsp.cs.uiuc.edu are enclosed in "<>".) <...almost nobody makes use of the fact that classes are objects in Smalltalk...> An evolving style of programming here at Tek (best summarized as "Class Variables Considered Harmful To Inheritance"), involves making heavy use of class instance variables for encapsulating information common to all instances of a class. For instance, individual Strings need to know how to concatenate themselves with each other, find Characters in themselves, and other things that are unique to individual Strings. But if one considers that the state of being a String involves some knowledge of line termination conventions on a particular system, then it becomes obvious that String class (which is where the information concerning the state-of-being-a-String, or "Stringedness", is stored) should maintain that information. In the past, we would have stuffed a line terminator in a class variable and been happy -- Strings and their subclasses could access it directly -- very efficient. But what about an application that needs to cross boundaries -- have Unix Strings and MS-DOS Strings at the same time? Class variables are shared among subclasses. By forcing Strings to treat their class as an object by asking it for line termination information, subclassing easily handles the situation. The subclass, say "PcString", is a bona-fide object, with its own instance variables, one of which contains the line termination sequence unique to MSDOS. Inherited methods that deal with lines work with either Strings or PcStrings. This has gotten a bit long-winded, but to summarize: classes-as-objects is an under-utilized, under-appreciated concept in Smalltalk, that has practical, intuitive applications. It is also misunderstood and misused, and people exploring "the tricks one can do" with it have tended to give it a bad rap by writing obscure, "tricky" code. Here, here! When you need a screwdriver, don't try to make do with a hammer! And if you pound nails with that screwdriver, you deserve the results! :::::: Software Productivity Technologies --- Smalltalk Project :::::: :::::: Jan Steinman N7JDB Box 500, MS 50-470 (w)503/627-5881 :::::: :::::: jans@tekcrl.TEK.COM Beaverton, OR 97077 (h)503/657-7703 ::::::