Sai wrote:
There is no need to have another mediator between the controller and the GUI.
I misnamed Mediator, -- it should actually be Model, for a complete MVC pattern:
-- In GUI, all controls are private, it knows nothing about Controller, and keeps a reference to Model. When GUI controls change, GUI updates the Model. GUI actually implements Observer, so that it can update in response to Model change. For example, if in the "Seats To Book" text field the user types a number greater that the number of seats left in the table, the model can set its boolean field bookingAllowed" to false. This will update the GUI (make the "Book Flight" button disabled).
-- Controller only calls the public methods of GUI to register the action listeners, it knows nothing else about GUI. If controller needs some values from the GUI, it would call the corresponding accessor methods in the
Model (not the GUI). If instead you call the public methods of the GUI to get the values, your controller is too tightly coupled with the GUI.
-- Model holds all the values and has a set of get/set for each control. Model extends Observable, and notifies the GUI of the changes in the model.
How's that?
Eugene Kononov.