View this PageEdit this Page (locked)Attachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

spring 2004 midterm - 4: prof. leblanc

4. Changed/Update mechanism

(a) Describe the sequence of messages that result in the ClockText view of the Clock model being updated.

  1. An instance of Clock receives nextSecond from a SecondsTimer.
  2. nextSecond sends the message: self changed: #time (it goes to itself).
  3. The Clock receives the changed: message from itself and the corresponding method sends update: #time messages to all of the dependents of the clock.
  4. An instance of ClockText is a dependent of the clock. Upon receiving the update: message and recognizing that the #time is the aspect that has changed, it sends display to its model (the clock) to get the text to display on the screen. Upon receiving the result, it changes the time on the screen.

(b) Why go to all of this trouble?

Using the MVC approach results in a much better structure, with minimal information sharing. The reusability of Clock is greatly improved (as in AlarmClock, VCR, etc.). Multiple views can operate together, with none knowing about the others.

Link to this Page