Knowledge Systems Corporation
Copyright ©1994 Vikas Malik
Translation to LaTeX by Matt Curtin <email@example.com>
All Rights Reserved. This FAQ may be posted to any USENET newsgroup, on-line service, or BBS as long as it is posted in its entirety and includes this copyright statement. This FAQ may not be distributed for financial gain. This FAQ may not be included in commercial collections or compilations without express permission from the author.
This document is also available in PostScript.
self refers to the receiver of the message. It is usually used within a method to send additional messages to the receiver. self is frequently used when it is desired to pass the sender object (self), as a message argument, to a receiver who requires knowledege of the sender or who will in some way manipulate the sender.
super refers to the superclass of the class that defines the message sent to the receiver. super is mechanism by which a sender can overide its own defined method hierarchy.
shallowCopy returns a copy of receiver which shares the receiver's instance variables.
deepCopy returns a copy of the receiver with shallow copies of each instance variable.
Class instance variables are similar to class variables, except that they are created for each subclass of the defining class. When a class declares a class instance variable, a new variable is created for each subclass of that class. Each subclass then has its own instance of the variable and retains its own value for the variable, but each subclass has a variable with the same name. Only class methods of a class and its subclasses can refer to class instance variables; instance methods cannot.
An instance of SystemDictionary. SystemDictionary maintains all the names of classes, global variables and pool dictionaries in the system. Smalltalk is the sole instance of the class SystemDictionary.
An OrderedCollection can be used to implement stack and queue operations. A stack is implemented by using addLast: anObject and removeLast methods for pushing and poping respectively. A Queue is implemented by using addLast: anObject and removeFirst methods.
An array is a fixed size collection whereas a set can grow in size. An array has integer keys and a set is not keyed. A set enforces uniqueness upon its members.
The methods of a class are organised in logical groups called protocols. Classes are grouped together into groups called categories.
By sending message halt.
= is a test for equality. == is a test for identity (same object).
Except for some special classes like Symbol, Character, and SmallInteger, two cases of a value (eg. 1.54) will not be the identical object, just one with equal value. The special cases are ``special'' and any variables that points to such an object will be by definition ``Identical''.
By using the following enumeration messages.
perform: method is used to tell an object to execute a method whose name, rather than being hardcoded, is sent as a parameter. This means that the name of the message need not be know until runtime.
anObject perform: #methodName
detect: aBlock returns the first element of the collection for which aBlock evaluates to true. select: aBlock returns a collection whose elements are the elements of the receiver for which aBlock evaluates to true.
A collection whose elements are true and false.
collect:aBlock returns a collection which contains the results of performing the same operation on each element in the receiver collection.
subclassResponsibility method is used to defer the actual implementation of a method.
shouldNotImplement method is used to indicate that a subclass wants to undefine a method defined in a superclass.
self, super, and thisContext.
A SmallInteger has fixed number of bytes and a LargeInteger has variable number of bytes.
Symbols are similar to strings except that they are unique. This means that whilst one can create several string objects containing the same sequence of characters, there will only be exactly one instance of a symbol with a given sequence of characters.
A Bag can have duplicates whereas a Set contains no duplicate objects.
In Chaining, one message can follow on after another. In this case the second message is sent to the object which is the result of the first message.
anObject msg1 msg2 msg3
In Cascading, each message is followed by a semicolon (;) and another message. In Cascading, subsequent messages are sent to the first receiver.
anObject msg1; msg2; msg3
yourself method returns self. It is usually used while cascading messages like add:.
| aCollection | aCollection :=3D OrderedCollection new add: 1; add: 2; yourself.
In the above example add: returns its argument, not the receiver.
Therefore, yourself message is sent to do the proper assignment of an OrderedCollection to aCollection variable.
isMemberOf: aClass returns true if receiver is an instance of aClass.
isKindOf: aClass returns true if receiver is an instance of aClass or one of its subclasses.
Method new is defined on instance side of class Behavior.
An IdentitySet is faster that a Set because == is a faster test than =
Modifying a collection while iterating over it will give unpredictable results.
Employees do: [:anEmployee | anEmployee isProgrammer ifTrue: [ Employees remove: anEmployee]]
Above example will not work as expected since we are changing the size of Employees collection while iterating over it. Making a copy of the collection will avoid the above problem.
Employees copy do: [:anEmployee | anEmployee isProgrammer ifTrue: [ Employees remove: anEmployee]]
nil is the only instance of the class UndefinedObject and it is the default value for any new variable until a specific value is assigned to it.
Pool dictionaries are created for providing access to pool variables to several classes that are not related by inheritance.
A literal is a piece of Smalltalk code that the compiler converts immediately to an object. Literals can be freely included in the programs just by typing them.
MVC stands for Model-View-Controller. Model stores information/data. Model notifies its dependents whenever one or more of its variables is changed. View is the component for displaying output. Contoller is the component that enables the user to interact with, or control, the application.
An aspect is a piece or subset of model's domain information.
A dependent is an object that is dependent on the information residing in a model. A dependent object is usually a view, a window, or another model and is contained in dependents collection of a model.
aModel addDependent: aDependent.
This method adds aDependent to aModel's dependents collection.
aModel release replaces aModel's dependents collection with nil.
The changed/update mechanism is used by a model to broadcast a notification of change to all its dependents.
A changed/changed: message sends an update message to all of receiver's(model) dependents.
The prototype for an update method for a view is
update: anAspect anAspect =3D anAspectOfInterest ifTrue: [ self invalidate]
Invalidate messages initiate a view's redrawing process.
invalidateRectangle: aRectangle invalidates only that area of the view defined by aRectangle.
By using its instance variable sensor, which references a TranslatingSensor.
A ValueHolder is a value model. It holds simple model objects like numbers, strings, etc. A ValueHolder is created by sending asValue message to any object or sending with: anObject to ValueHolder class
anObject asValue. ValueHolder with: anObject
A ValueHolder understands value/value: protocol. value message is used to access its value. value: anObject message is used to set its value to anObject.
A channel is a value model that is used as a common access point for a changing value.
By sending onChangeSend: aChangeMessage to: anInterestedObject to a ValueModel. The advantages of this approach are:
A DependencyTransformer implements the behavior needed by an object to register interest in a value model. A dependencyTransformer is defined as a dependent of a value model and converts an update message sent to itself into a specific change message and sends this change message to the interested object.
Using setValue: disallows all updates. retractInterestsFor: only disallows a specific update, allowing all others to proceed.
An AspectAdaptor is a ValueModel whose value actually belongs to another object called the subject. The task of AspectAdaptor is to interface the general-purpose view object to just one aspect of the model(subject). An AspectAdaptor is created as follows:
| aa | aa := AspectAdaptor subject: Employee new. aa forAspect: #ssn.
One can change the ssn of this employee by using aa value: aNumber. An AspectAdaptor needs to know which messages to send to the model to access and assign value to one of its aspect. In the above example value/value: messages sent to aa are converted into ssn/ssn: and sent to subject. forAspect: #ssn message sets the getSelector to #ssn and sets the putSelector to #ssn: The value method of AspectAdaptor is implemented as
value ^subject perform: self getSelector
The subject channel is the ValueHolder containing the subject of an AspectAdaptor. It is useful when several AspectAdaptors share the same subject and its value of this subject needs to be changed.
A PluggableAdaptor uses blocks to adapt a model to a view instead of using just selectors like AspectAdaptor. The blocks are called the getBlock, the putBlock and the updateBlock. These blocks get executed when a PluggableAdaptor receives value/value: and update messages. A PluggableAdaptor can be created as follows:
| pa | pa := PluggableAdaptor on: Employee new. pa getBlock: [ :m | m salary * 30 ] putBlock: [ :m :v | m salary: (v/30)] updateBlock: [ :m :a :p | .... ].
On sending value message to pa, getBlock gets executed. It send salary message to employee(model), multiplies the result by 30 and returns it. In this way, one can perform more complex operations on model as a result of just sending the value message to pluggableAdapator.
An IndexedAdaptor is similar to AspectAdaptor except that its subject is a sequenceable collection and value/value: messages are dispatched to the subject as at:/at: put:.
A SelectionIinList is a selection model. It has two instance variables.
SelectionInList does not have any dependents. Both of its instance variables have two dependents: the SequenceView and the SelectionInList object itself.
A BufferedValueHolder is a ValueModel that references two other value models called its subject and trigger channel. When a BufferedValueHolder receives a value: message, it holds onto the new value and does not update the subject until trigger channel becomes true.
An IndexedAdaptor operates on a numbered instance variable in the subject, whereas an AspectAdaptor operates on a named instance variable.
Class BlockClosure implements the block notation in VisualWorks Smalltalk. In VisualWorks, blocks are close to being closures. One can declare variables local to the block, and the names of block parameters are local to the block.
The launcher is the root of the VisualWorks development environment. Various development tools can be launched (or opened) from its menu. The launcher is implemented by VisualLauncher which is a subclass of ApplicationModel.
A VisualWorks component is a SpecWrapper. A SpecWrapper is wrapper that contains a widget, decoration for the widget, a copy of WidgetState object and ComponentSpec.
An active component is a VisualWorks component whose widget is a View and has a Model and a Controller. A passive component is a VisualWorks component whose widget is not a View and it does not depend on a model and a controller.
A widget is a visual part responsible for the visual representation of a VisualWorks component.
An ApplicationModel is responsible for creating and managing a runtime user interface. An aspect model contains a single aspect of info and provides the model behavior for a single VisualWorks component. The relationship between an application model and an aspect model is that an application model contains one or more aspect models.
A keyboard hook is a used for intercepting all the keyboard activity going to a VisualWorks component. It is a block which is evaluated just prior to the widget controller handling a keyboard event. Keyboard hook can be set as follows:
| comp | comp := anApplicationModel builder componentAt:= \#myComponent. comp widget controller keyboardHook: aBlock.
The Transcript is a text window used by the system to report important events. The global variable Transcript is an instance of the class TextCollector in VisualWorks and class TranscriptWindow in Digitalk.
A dispatcher is used by a widget controller to dispatch notification and validation messages to the ApplicationModel. A dispatcher is an instance of class UIDispatcher.
A ComponentSpec describes properties and features of a VisualWorks component. ComponentSpec provides behavior for interface persistence in form of source code or text file.
A builder is an instance of class UIBuilder. It is used to construct a user interface according to the specifications. It also provides access to the runtime interface. Builder provides access to named components, the keyboard processor, the window and aspect models of a running application.
A FullSpec is a combination of a window spec and a spec collection. A window spec describes a window and a spec collection is a collection of component specs for all components of a window.
A resource is an object used by the builder to construct the interface according to the specs. Examples of resources are aspect models, menus, images, and labels. There are two types of resources:
The builder's source is an ApplicationModel that provides the necessary resources to a builder for building an interface according to the specs. It is kept in source instance variable of UIBuilder.
A builder uses the following variables to cache resources.
A lookPolicy object is an instance of one of the subclasses of the UILookPolicy abstract class. A lookPolicy object is used to create a VisualWorks component based on the componentSpec and the specific window environment's look and feel.
By sending policy: aLookPolicy message to a builder.
aBuilder policy: MotifLookPolicy new.
A VisualWorks component is built by either the component spec or by the builder's look policy object. Usually it is the look policy object that builds a VisualWorks component. A look policy object uses its instance methods, component building methods, to construct a VisualWorks component based on a ComponentSpec and look and feel of that particular look policy.
aBuilder window. aBuilder keyboardProcessor. aBuilder componentAt: \#componentID. aBuilder aspectAt: \#aspect.
A keyboard processor is an instance of class KeyboardProcessor. It directs keyboard events to the current widget controller. There is only one keyboard processor per window. A widget controller that takes focus has an instance variable, keyboardProcessor, used to reference its window's keyboard processor.
preBuildWith: aBuilder method allows anApplicationModel to make any changes to its builder prior to handling its full spec.
postBuildWith: aBuilder method allows any final changes to the interface prior to opening.
In the postBuildWith: method, the interface is completely built but it exists in memory only and window is not open. Whereas postOpenWith: method allows the application model to make any changes to the interface with the window open.
By sending the closeRequest message to anApplicationModel.
closeRequest method sends an update: #closeRequest to anApplication Model dependents (window is one of the dependents).
The subapplication is the application model that manages the subcanvas. The parent application is the application model that provides the subapplication as an aspect model.
clientKey is the message name which is sent to parent application to acquire the subapplication that manages the subcanvas.
majorKey is the name of ApplicationModel subclass that builds and runs the subcanvas component.
minorKey is name of the class method that returns a full spec describing the subcanvas interface.
By sending one of the following messages to aSubCanvas.
client: appModel client: appModel spec: aSpec client: appModel spec: aSpec builder: aBuilder
appModel is subapplication, aSpec is full spec of subcanvas, and aBuilder is an instance of UIBuilder.
ScheduledControllers is a global variable that refers to the only instance of ControlManager. It is responsible for managing all current window controllers.
ScheduledControllers currentController view
(anApplicationModel builder componentAt: #compID) widget
By sending takeKeyboardFocus to a VisualWorks component.
comp labelString: aString
comp beInvisible. comp beVisible.
comp enable. comp disable.
By sending displayStringSelector: aSymbol message to aSequenceView. aSymbol is the name of method used to display strings.
aSequenceView lineGrid: aNumber
Smalltalk Frequently Asked Questions
This document was generated using the LaTeX2HTML translator Version 96.1-h (September 30, 1996) Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
The command line arguments were:
latex2html -html_version 3.1 -split 0 smalltalkFAQ.tex.
The translation was initiated by C Matthew Curtin on Mon Jan 27 00:13:39 EST 1997