jeudi 23 juillet 2015

Observable pattern implementation in Java

I am currently Using Java's Observer/Observable Pattern and I was wondering: Why is there any need of the setChanged() method in its current implementation ? I understand that it is here so that we only have to call notifyObservers() once, at the end of our treatment.

That way, if we want to we can rollback any changes with clearChanged(). But still, we could do all the checking in our own implementation, and only call notifyObservers() when we absolutely want to update the Observers.

I'm probably missing something, but I don't understand why they didn't simplify it that way. Any ideas?

Aucun commentaire:

Enregistrer un commentaire