
Smalltalk-80 Course - Utrecht, June, 1990 - Part 1

		Introduction to Object-Oriented Programming and Smalltalk-80

Introduction
	Format - 2 nights
	Lecture + Exercises

Background
	OOP Background
	Smalltalk-72/76/80.1/80.2 at PARC
	Smalltalk and IPE's
	Smalltalk and Music

What is OOP?
	Objects and Classes
	Inheritance and Reuse

OO Design
	Evolutionary rather than Revolutionary
	The Importance of RP&ID
	Composition
	Refinement
	Factorization
	Abstraction
	Comparison

So What?

OOP Languages
	Criteria
	Question of the Day

The Smalltalk-80 Programming Language

	Objects
		Literal Objects
			3, 3.1415926, $c, 'hi, there', #(1 $a 4)
		Declaration, Naming 
		Keywords (Assignment and Return)

	Messages
		Unary, Binary and Keyword Messages
		Composite Message Examples
			(3 + 4) * (2 + 4)
			(0@0) extent: (1@1)
			(Cursor someInstance) displayOn: Display at: 20@20

	Messages, Blocks and Methods

	Boolean, Collection and Block Objects and Control Structures
		ifTrue: [], ifTrue: [] ifFalse: [], ...
		[] whileTrue: []
		someCollection do: []
			select: [], collect: [], detect: [], reject: []
		someNumber timesRepeat: []

	Scope and Extent of Names
		Local and Global objects

	Classes
		Class messages
		Class Variables
		Class instance variables

The Smalltalk-80 Class Library
	Structure and Architecture

	Protocol Families
		Magnitudes
			State: value
			Behavior: arithmetic, comparing, coercion
		Collections
			State: items, contents
			Behavior: adding, removing, membership, enumeration
		Streams
			State: contents
			Behavior: read/write
		DisplayObjects
			State: boundingBox, bits
			Behavior: box access, display, displayOn:, displayOn:at:clippingBox:rule:mask: 
		Models, Views and Controllers
			State: MVC connections
			Behavior: MVC responsibilities and central methods
		Music Protocol Families
			Magnitudes
			Events, EventLists
			EventGenerators, EventModifiers
			DisplayLists, LayoutManagers, DisplayListViews/Controllers

	The Protocol of Class Object
		Accessing: class
		Testing: = == isNil
		User Interface: inspect, browse
		I/O: printOn:, storeOn:, readFrom:

	The Protocol of Class Class
		Subclass/superclass access
		instance access

	Examples
		Numbers
		Geometrical Objects
		Forms and Display
		Streams

The Smalltalk-80 Programming System
	System Components: virtual image and virtual machine
		Compiler and Translator--VM and Native languages

	System Files: VI, VM, Sources, Changes, code files, data files
	VM Structure
		Memory Manager, Translator, System Primitives, User Primitives
	VI Structure
		System Dictionary: Smalltalk
			all classes and globals
		Globals
			Display, Transcript, Sensor, Undeclared, etc.
		Objects

	Portability
	VI Window System
	VI Tools

The Smalltalk-80 System's Software Tools
	Smalltalk-80 and IPE
		Open Systems
		Programmer as Reader
		Model/View/Controller

	The VI 2.X U.I.
		Mouse Buttons
			select/operate/view
			left/red - select button
			middle - yellow (option-mouse) - operate menu in button at top of scroll-bar
			right - blue (apple-mouse) - view menu (blue button) in view's label
		Selection in text, lists, graphics
		double-clicking and delimiters
		left-shift clicking and left-shift menu items

	The System Background Menu

	Workspace,
	Text and File Editors
	File List
	Terminals
	Clocks

	Object Inspectors
		field list and contents view
		printOn: message

	Code Browsers
		System Browser
			4 list views--category, class, protocol, message
			code view--definition, comment, protocols, method code
		Class Browser
		Hierarchy Browser
		Method List Browsers (senders, references, etc.)

	The Debugger (is your friend)
		Message stack
		Code view
		Receiver inspector
		Arg/temp inspector
		halting, MNU, other errors...

	ChangeList Management Tools
		ChangeList and ChangeSet

	ScreenSaver
	Projects

	Using the Tools as Applications
		TextEditor, Terminal, ...
	Using the Tools for Programming
		Programmer as Reader
		Example: Extending an Inspector
		Example: Programming an Up/Down Counter Example


Exercises

Starting the System
	Copy image and changes files
	Double-click an image OR
	Double-click a VM and select an image

Using the Window System
	System background menu

	Window menu (blue button) in label	
		(OR apple-mouse)
	Subview menus (yellow button) at top of scroll-bar
		(OR option-mouse)
	open/frame/move/collapse/close windows

The System Outline
	Background menu item
	Outline Usage
	Outline Contents (i.e., look through it...)

Using a Workspace
	Work mode--type/select/operate
	Evaluate:
		Display flash: ((100@100) extent: 200@200)
		5 timesRepeat: [Display flash: ((100@100) extent: 200@200)]
		Display + 3
		3 + 4 			"print it"
		Date today 	"print/inspect"
		Cursor someInstance 	"print/inspect"
		Date instanceCount 	"print it"
		Cursor allInstances 	"inspect"
		Sensor waitButton 	"do it, then press a button"

	Using a temp variable
		| time |
		time _ Time now.
		Transcript show: (time printString); cr.
		time inspect
		
		| t |
		t _ 0.
		[Sensor anyButtonPressed]
			whileFalse: [t _ t+1.
					Transcript show: t printString; cr]

	Using a Global variable
		MyStuff _ OrderedCollection new.
		MyStuff add: (Time now).
		MyStuf add: (Cursor someInstance).
		MyStuff inspect

Using Inspectors
	4 inspect
	#(1 2 3 4 5) inspect
	Smalltalk inspect

Learning the Class Libraries
	Look at Magnitude Classes
		What's the common protocol?
		Where is subclassResponsibility used?
		Where's it overridden?
	Look at Collections
	Look at DisplayObjects
	Look at Views/Controllers

Browser Exercises
	System browser
	Find category 'Numeric-Magnitudes'
	Select class 'Date'
	Select protocol 'comparing'
	Select message '='
	Read method for '='
	Look at code view yellow-button menu
	List view yellow-button menus
		Category--find class, file out, spawn
		Class--comment, definition, hierarchy, protocols
			spawn, spawn hierarchy
			inst var, class var, class refs
		Protocol
			file out
		Message
			cross-referencing--senders, implementors, messages

	Find class EventList
	Spawn its hierarchy
	...


File I/O
	File out a method from the browser
	Open a file list and read the file.

Project Exercises
	Open a new project.
	Enter it.
	Open a browser, go to some category/class/protocol/method
	Exit project
	Re-enter project
	...


Coding Examples (...)

	1) Build an up-down counter.
	Add a Category "Demo-Counter".
	Define class "CounterModel" with one instVar--value.
	Add protocols accessing, printing.
	Add methods increment, decremnent, value, printOn:.

	Define CounterView
		Subclass View
		Add display and update methods

	Define CounterController
		Subclass MouseMenuController
		Add initialize (for menu) method.
		Add menu message (increment/decrement) methods


	2) Turn the Counter into a Calculator

	3) Implement a BinaryStack class

	4) other examples...

