Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
(6) Changed/Update Mechanism - Prof. LeBlanc
One of the members of a CS2340 team unfortunately missed all of the lectures on UI because of his European vacation. He's trying to get his first MVC interface to work, and he's asking for your help. Answer his questions below either by providing code from the Clock example or by explaining what happens.
- Okay, I've got this Clock object, and I've got this ClockText that's going to display the time/ When I'm first setting the text area, how do I arrange things so that the ClockText acts as a view for the Clock? (6 points)
- When ClockText is created, it is sent a message with the Clock as a parameter. It sends itself as the parameter of an addDependent: message to its Clock instance
- Now, the time has changed. How does the ClockText find out that it has to display a new time and get the new time to display? (10 points)
- The Clock sends changed: to self. An update: message goes to all dependents. The ClockText receives the update: message and then sends the appropriate query to the clock to get the time.
- That seems like an awful lot of work! Why not just have the Clock display the correct time at each second. Why involve ClockText at all?!!!? (4 points)
- Minimize linkage between clock and its interface
- possible to change interface easily withouth impacting Clock
- can even support multiple views of one model
Link to this Page