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

Sp2002 Midterm Review: Help the MVC Novice

Back to Spring 2002 Midterm Review


(4) You want to tell clockText that it is a dependant of the clock. Code similar to 'clock addDependant: clockText'.

(5) The clockText would find out from update:. Which is caused by the clock calling announcing it has changed, and sending that information to all of its dependants. From there the dependants decide whether the information is relevant to them, if it is, they do their specific action. In this case it would be displaying the updated time.

(6) This requires that the clock know to much information and therefore takes away from the beauty of the system. Clocks are universal, if you make your clock display the time, you can use it for only one thing...a digital clock. But keeping them seperated allows for reusable code in such things as a analog clock or date book.

Theres your answer Francisco.
Brian Pashel

(a) I agree, Clock should not know about its display at all, but should announce to the world that it is changing its time. Then the database of dependencies will recognize that ClockText is dependent on Clock (Because we specified that), and ClockText will update itself when Clock changes.

(b) See above, Clock sends out a message to its dependencies that it has changed. Its dependencies, ClockText, would then update itself.

(c) You may want a non-displayed clock such as a punch card system or an invisble timer.

(b) I agree that Clock should send a message that its time has changed, but isn't it the responsibility of its dependents to ask for the new time based on the fact that time has changed?
Kathryn Leland

1. When Clock's time increments by a second, Clock knows there is a change.
2. Because something important has changed, Clock must then announce an event to all its dependants.
3. This announcement goes to the dependant's in form of an update message.
4. If a dependant is set to update when that event has occurred then it must perform whatever message is associated with that event.

If display is to be performed, and it asks the Clock for the time, then yes, in this case, it is the responsibility of the dependant to ask for the new time. However, the message to be performed could also be rotate or changeColor.

Hank Wilde

Kathryn I think your right. Check the top of page 146 in the book. "The view gets told to update, then it has to ask the model for the value, and then it updates."
Charlie Murff

Link to this Page