I am changing my application to use the MVC pattern. Currently in the notify() method for the observer I am sending the entire model to the View. Is this correct or should be be creating seperate Events and send them to the clients?
The Observable
public interface Observable<T> {
void notifyObservers(T model);
void addObserver(Observer<T> o);
void removeObserver(Observer<T> o);
void removeAllObservers();
}
The Observer
public interface Observer<T> {
void notify(T o);
}
The model sends notifications to view like this
@Override
public void notifyObservers(ModelViewInterface model) {
for(Observer<ModelViewInterface> o : this.observers)
o.notify(model);
}
And I notify them like this
notifyObservers(this);
In the ModelViewInterface
I only have the getter methods (no setter methods) and my model implements this interface.