






Hotspots: Admin Pages | Turn-in Site |
Current Links: Case Final Project Summer 2007
Fall2001 Midterm Review: Help the MVC Novice
Link back to Fall 2001 Midterm Review
Ok I sort of have an answer to (a) and I also have a question.
Answer: Basically you set the ClockText model to the clock and add the ClockText as a dependant to the model. And in the clock any time an aspect changes, you call a method change #aspect. Likewise in the ClockText windowyou have a method update, where any time it gets call it passes in a ascept and you can make the appropriate changes.
My question is, is aModel the instance of Clock, and if so from where do we call the method to add aModel as the model of ClockText. I know this isn't something we would probably use but I am still curious. Thanks Robert Schierholz
a) You don't. In this case ClockText is a view and Clock is a model. The model should never know anything about the view in MVC. What you can do is tell the ClockText that it is dependent upon Clock. That way clock could notify ClockText that there is an update without knowing anything about it via calls like (self changed: #time).
b) Simple. Clock will send out a self changed: #time every time the time has changed. ClockText will be notified of this because update: will be called on it with #time as the parameter. The ClockText can then query clock for the time and display it
c) This method would be somewhat unreusable. Lets say that under the old model you wanted clock to have a digital display. All you would have to do would be to create the new display and it would require no changes to Clock. Under the new model you would have to once again go through teh steps of message passing
Jared Parsons
On a question like this, should we be naming the relevant messages, like addDependant: and update:, or should we just describe what needs to be done in a more general sense?
Brandon Yarbrough
Link to this Page