Setting up an MVC Model

Steps for implementing MVC: Want to set up a communication framework among the model, view, and controller
  1. Design a listener interface for views (observers): The model uses the listener interface to notify the views of changes to the model.
  2. Implement model with methods for controller to change model and for the view to access model info
    1. implement query methods so views can access state information
    2. implement registration/de-registration methods for views
    3. implement change methods for the controller. These methods will:
      1. change the model's state
      2. call a notification method
    4. implement notification methods for the views. Specifically, for each method M in the listener interface, implement a notifyM() method in the model that notifies listeners with the old value
  3. View implementation
    1. register the view with the model at view creation time (typically in the constructor)
    2. have view implement listener interface and repaint affected screen regions
      1. if the view consists entirely of pre-defined widgets, the widgets will automatically redraw themselves
  4. Controller implementation: translate events into change method calls on the model
    1. typically bundled with the view, because each view is so idiosyncratic that it's tough to write independent controllers