
C Sc 335 Section 2- and 3-Nov
Read this page and discuss Java's Observer class and its Observable interface.
Begin the exercise in pairs (or solo)
Model-View-Controller (MVC) is a classic design pattern often used by applications that need the ability
to maintain multiple views of the same data. The MVC pattern hinges on a clean separation of objects into
one of three categories — models for maintaining data, views for displaying all or a portion of the data,
and controllers for handling events that affect the model or view(s).
Because of this separation, multiple views and controllers can interface with the same model. Even new
types of views and controllers that never existed before can interface with a model without forcing a
change in the model design. The MVC abstraction can be graphically represented as follows.
Events typically cause a controller to change a model, or view, or both. Whenever a controller changes a
model’s data or properties, all dependent views are automatically updated. Similarly, whenever a
controller changes a view, for example, by revealing areas that were previously hidden, the view gets data
from the underlying model to refresh itself.
Observer/Observable
The observer pattern usually plays a part in MVC. Java provides support with the Observer class and
Observable interface. The design allows one Observable to notify all registered observables
that a change of state has occurred.
for each o in my_observers