Student Originated Software 1997-1998
Fall Quarter

A Software Engineering Course at
The Evergreen State College

Next Week's Assignment

Today's Lab for Tuesday - skim the VW Tutorial (VWT), Ch. 3-4. Lab - do the tutorial (the VW GUI Builder) (Read (or reread) Ch. 17 & 18 due on Thursday in class - exercises on collection classes: 15.2, 15.3, 15.4 -- Build a binary tree class,Assignment for Chapter 15 -- 15.5, 6, 15.12,13 due after lab - a mockup of some possible screens for HiHo Thursday lecture -- possible guest lecturer) - Logical operations, undefined objects and Types. skip ahead to read ch. 21?

-Workshop on Today's Assignment Form into groups of about 5. Discuss your solution to one of these problems (half of the class should do each). Feel free to add to and embellish any one answer! Appoint a presenter to present your combined solution. 20' discussion - 20' presentation(*11.4 (once you've enetered FinancialHistory, design an extension to it and try that out.) Discuss the modification that you made to FinancialHistory so that it would write to the System Transcript. How did you find out what you needed in order to do this? What questions do you still have? *13.15 - What alternative representations of Rectangle might you consider? What would an implementation of NewRectangle look like? Present your design for this new class

Smalltalk OIDs

shallow vs deep copy, & complex objects

p.s. if you want to put only unique objects into a set,

use IdentitySet, not Set

MySet := MyCollection asSet.

| myName yourName |

myName := 'judy'.

yourName := myName.

myName := 'judith'.

yourName.

| myName yourName myColl aDate |

myName := 'judy'.

yourName := myName.

myName := 'judith'.

aDate := Date today.

myColl := #('judy' 'judith' myName yourName aDate) asSet.

myName := 'judy bayard'.

myColl do: [:item| Transcript show: item printString;cr].

Enumerating collections*s

do: same operation on every element of the collection

collect: like do:, but returns a collectin with the results.

select: tests every element and returns those which pass.

reject: fail.

detect: returns the first element which passes the test.

inject:into: feeds the result of one operation into the next.

do NOT add or remove elements while iterating over it!

MyCollection do: [:piece | piece reset].

( 10 to:35 by: 5) do: [:i | Transcript show: i printString; cr]

Names := People collect: [:person | person name].

Oranges := Fruits select: [:fruit | fruit isOrange].

Total := Numbers inject:0 into:

[:subtotal :number | subTotal + number].

Collection Classes (cont)

MyColl := OrderedCollection new.

My Coll := Array new: 27.

MyColl := Set with: #red with: #green with: #blue

MyColle := #('Goodbye' 4 #now).

Creating collection classes -

Testing collections - size, isEmpty, includes:anObject.

Converting collections - asBag, asArray, asSortedCollection, etc. MyValues := MyDictionary asSet.

My Keys := MyDictionary keys asSortedCollection.

The (~50!) Collection Classes (cont)

A collection is an object which contains a group of other objects, known as elements of the collection.

Operations - add, remove, enumerate.

Most Smalltalk collection classes are heterogeneous [Dhatch] except String, Symbol and ByteArray.

The most useful - Set, Bag, Array, Dictionary, OrderedCollection, SortedCollection*..

What collection class to use - Do the elements need to be ordered?

How will the order be determined?

Will elements be accessed with a key?

Will duplicate elements be allowed?


For more information contact
[ Evergreen Home Page | Academic Programs ]


Created by: SoSwEbGrOuP
E-mail: ringert@evergreen.edu