| ||
Student Originated Software 1997-1998
| ||
A Software Engineering Course at The Evergreen State College | ||
|
Student Originated Software 1997-8Object-Oriented Programming (Smalltalk)Lecture 2blast time in class:--------- block - a deferred sequence of messages evaluated when the block receives the message
aBlock := [a:=0]. aBlock value
MyBlock := [:anObject | anObject print].
anotherBlock := [:parm1 :parm2| |tmp| tmp := parm1 incorporate: parm2. tmp := rehash. ]
executing blocks MyBlock value: 'This is a string sent to print'. value, value:, value:value:, value:value:value: valueWithArguments:argArray (> 3 arguments.
----------------
the smalltalk virtual machine (oe20)-- interprets code as it comes in
Application Development Environment
in Lab - last Tuesday, Chapters 6 & 7. add a new method to an existing class (Number) do a small application
some useful browsers and menu operations..... hierarchy implementors of... users of... cookbook help
The Spending App -- new category, with classes & methods).
self new initialize self new setInitialBalace:anAmount ^self new setInitialBalace:anAmount
setInitialBalance: anAmount cashOnHand := anAmount. expenditures := Dictionary new.
totalSpentOn: reason (expenditures includesKey: reason) ifTrue:[^expenditures at:reason] ifFalse:[0]
spend:anAmount on:reason expenditures at: reason put: (self totalSpentOn: reason) + anAmount. cashOnHand := cashOnHand - anAmount.
printOn:aStream
super printOn:aStream. aStream space. aStream nextPutAll: 'balance:' cashOnHand printOn: aStream. expenditures keysAndValuesDo: [:reason :amount | aStream cr. reason printOn: aStream. aStream tab. amount printOn: aStream]
invoking the app: | mySpendingHistory | mySpendingHistory := SpendingHistory initialBalance: 60000. mySpendingHistory spend: 1000 on: 'rent'. mySpendingHistory spend: 500 on: 'food'. mySpendingHistory spend: 100 on: 'vet'. mySpendingHistory spend: 25000 on: 'new car'.
"inspect" mySpendingHistory you can modify the collection from the inspector "inspect" the Smalltalk dictionary.
----------- saving your source code file out as ... Spending.st
------- using the file browser, 'spawning' a new (file) broswer
--------
OO Design Spec for the Spending App.
Like an ER diagram, but with methods!
Ch 7 - The System Transcript Transcript refers to an instance of TextCollector show: aString cr tab
Object printString returns a string with a printable representation of the receiving object implemented using printOn:, which is redefined in subclasses of Object.
Transcript show: (2 raisedTo:10) printString.
>>>How does Smalltalk decide which method to invoke when I send a message, since there are several methods of the same name?
Transcript cr. Transcript tab. Transcript show: 'String on a new line'; cr. Transcript show: (3+4) printString; cr. Transcript show: (22/7) printString; cr. Transcript show: (42 raisedTo: 42) printString; cr.
-------------
Chapter 8 - Class Point..... information hiding encapsulation
-------------
Chapter 9 - Other kinds of Browsers class browser hierarchy browser spawn hierarchy
Beware of changing classes w/ multiple browsers open! use update!
-------------
Assignment for Next week Inheritance, class variables and abstract superclasses.
So far, it looks like we might be able to stick with the syllabus. How's the pace?
- Tuesday - Asst (due) - Read Ch.11,12, 13.
Programming Assignment....
Turn in Exercise 10.1, 10.4, 10.6, 10.7, and 10.10. You may work on these exercises with a group, but please write them up with at most one other person. Two persons may turn in one programming assignment.
- Thursday - Unordered Collections. Asst (due) - Read Ch. 14.
|