Instructors' Guide


Introduction Terminology Expressions Control Objects Inheritance Technology Summary

Technology

Inheritance, in combination with message passing, allows for powerful programming techniques. As an example, an illustration is given of the cooperation between two objects employing the Model/View paradigm. The model class Ctr, depicted in slide sm-tech-1, may be regarded as embodying the proper functionality of the application.
  Model subclass: #Ctr 
Model
... initialize value := 0. TV open: self. ... add: anInt value := value + anInt. self changed: #value.

slide: Smalltalk -- technology (1)


  View subclass: #TV 
View
instanceVariableNames: '' TV methodsFor: 'updating' update: aValue Transcript show: 'ok'; cr . TV class instanceVariableNames: '' TV class methodsFor: 'instance creation' open: aCtr self new model: aCtr

slide: Smalltalk -- technology (2)

A view class defines an object that may be used to monitor the behavior of the model instance in a non-intrusive way. To support monitoring, the model class Ctr needs to install one or more view objects during initialization, and further, it must notify its view object(s) whenever its contents have been modified, as in add. See slide sm-tech-2.

The view class TV defines a class method open to create a new view object for an instance of the Ctr class. It must further define a method update (that will automatically be invoked when the Ctr instance signals a change) to display some message, for example the value of the Ctr object monitored.

The programming environment forms an integral part of the Smalltalk system. The code depicted above (which clearly reflects the object nature of classes) is usually not the result of text editing, but is generated by the system. The Smalltalk programming system, in particular the standard library, however, will take some time to get familiar with.