Eugene Hsu
Peter Phan

Assignment 5: Smalltalk Addressbook Classes

Figures

Source code

Sample interactions

Class SortedDirectory

The SortedDirectory class was designed with the AddressCard in mind. It is helpful since no predefined collection had the two necessary features: Since we only want one association keyed State, for instance, it is helpful to have the unique keying provided by Dictionary. Since we want to organize notes in cleanly, it is helpful to have the sorting capabilities of SortedCollection. The SortedDirectory class provides the best of both worlds, with a pleasant and uncluttered interface.

The methods available within SortedDirectory allow users of the class to easily access and modify data. Several of the notable methods are:

The design decision to not make SortedDirectory a subclass of some sort of collection was motivated by Smalltalk's apparent inablility to effectively hide methods of superclasses.


Class AddressCard

AddressCard is a subclass of SortedDirectory. While the methods inherited were already quite robust, it was helpful to make a few modiciations to make the class more user-friendly. Some notable changes are: The substring searches offered by the contains: and key: contains: allows the AddressBook class to have a very powerful searching interface.


Class AddressBook

AddressBook provides powerful searching methods. Within it is a SortedCollection and a method, cards to access it. By doing this, the user can modify the sortBlock to orgazine the AddressCards nicely when it is displayed using the display: method. With such available methods, it is incredibly simple to filter out cards in infinitely picky ways.