Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!news.mathworks.com!news.kei.com!nntp.coast.net!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!matilda.vut.edu.au!rhh
From: rhh@matilda.vut.edu.au (Robert Hinterding)
Subject: Re: smalltalk beginner
Message-ID: <Dp3v1C.9BD@matilda.vut.edu.au>
Organization: Victoria University of Technology
References: <4jis0u$r6h@harbinger.cc.monash.edu.au>
Date: Sun, 31 Mar 1996 00:08:00 GMT
Lines: 57

alex@insect.sd.monash.edu.au (Alex Koutsoumbos) writes:

>As a beginner smalltalk beginner, I'm having some difficulty with some of the 
>oo terminology used regarding the language.

>My understanding is that an object is an instance of a class, as is the case
>with oo languages such as Eiffel and C++ (you can argue about the latter).
>However, in smalltalk everything is an object...my understanding of this is 
>that object is a superclass that all other objects inherit from and the word
>object is really denoting a class.  Secondly, what exactly is meant by the term
>class and instance variable, to me a class variable has class scope and is 
>shared by all objects (instances) of the class, and instance variables are 
>used to represent the state of the object.

>I would clarification of some of the oo concepts in the context of the 
>smalltalk language.

Here is a simplified explanation.  It will contain some white lies, but full 
details would confuse at the moment.  Smalltalk is taught at Monash (I think),
so for further info, get a book from the library otherwise go and see a lecturer
such as Christine Mingins.

In Smalltalk everything is an object, there are no typed variables as in C++.
All objects are instances of a Class.  Think of a class like a factory, so a 
car factory produces cars and Class Car will produce instances of class Car.
So in Smalltalk everything is an object, and all objects are instances of some
class.  Classes are also objects and are instances of Class Class, but ignore
this for the moment.   A Class will define methods (operations) for both the
Class and instances of the class, ie what the Car factory and the cars can do,
(these are different as you would not expect a car factory to drive at 100 kph,
but that would be OK for cars).  So we have class and instance methods, class
methods define what a class can do (mainly produce instances) and instance
methods which define what an instance of a class can do.

In Smalltalk there are three types of variables, globals, class variables and
instance variables. Globals can be accessed anywhere, Class variables are global
to all instances of that class, and instance variables are local to that 
object.

A Class defines what are its class and instance variables are.  Every instance
of that class will have access to the class variables of that class, and to
only its own instance variables. So instance variables of a car could include
its colour, its current speed and who is driving it.  These define its current
state.

So objects, (an instance of some class) are like a combination of variables
that define what information is held about instances of the class, and the
operations (methods) that can be performed on those variables.

Hope that helps a bit.
Robert

-- 
Robert Hinterding                       Email: rhh@matilda.vut.edu.au 
VICTORIA UNIVERSITY OF TECHNOLOGY       Fax:   +61 3 9688 4050
P.O. Box 14428, Melb Mail Centre        Phone: +61 3 9688 4686              
AUSTRALIA 3000                          Home Page: http://www.vut.edu.au/~rhh
