Drazen Grabovac wrote:
Model is the one that implements the observer pattern so it can notify interested objects when the state changes.
Using the observer keeps the model decoupled from views and controllers.
Sort of. I think you understand but just to clarify in MVC, View is the Observer (Listener), Model is the Subject.
A View can register itself to the model it is interested to observe/listen using Model.registerListener(itself<View). After that when a model is changed the model calls Observer.notify(itself<Model) for all the registered Observers, the signature might vary, the idea is to notify all the Observers.
Note that you will not use this pattern much in Web MVC, but in Desktop applications, this pattern is very common.
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional