- Smalltalk classes correspond to groups, and Smalltalk instances
correspond to individuals.
- Class definitions generally include instance variables, also
known as member variables, fields, or slots.
- If you want to define a simple class, with instance variables only,
then click on that class's superclass in the class-hierarchy browser
and instantiate the following pattern:
superclass name subclass: #class name
instanceVariableNames: 'instance variables'
classVariableNames: ''
poolDictionaries: ''
- If you want to create an instance of a class, then instantiate the
following pattern:
class name new
- Setter and getter methods provide a route to instance-variable
assignment and reference. Collectively, setters and getters are called
accessors.
- If you want to be able to assign an instance-variable value using a
setter, then instantiate the following definition in the
class-hierarchy browser:
variable name: aValue
^variable name := aValue
- If you want to be able to refer to a instance-variable value using a
getter, then instantiate the following definition in the
class-hierarchy browser:
variable name
^variable name
- You can define setter and getter methods for derived attributes.