I asked here how I should handle the situation when I need to inform observers only when specific attribute of object changes. I received very nice reply with reference to GoF where is written: Blockquote Specifying modifications of interest explicitly. You can improve update efficiency by extending the subject’s registration interface to allow registering observers only for specific events of
Tag: observer-pattern
How to observe different attributes of same types with the Observer pattern?
I implemented the Observer pattern in an MVC application so a bean can listen for changes in the model. Since I’m in Java8 I’m using Observer and Observable from Java.util. Here’s part of what I coded: I think the implementation is correct because, in a simple test that I made, the changes to Ids and Names are correctly read by
Observer is deprecated in Java 9. What should we use instead of it?
Java 9 came out, and Observer has been deprecated. Why is that? Does it mean that we shouldn’t implement observer pattern anymore? It would be good to know what is a better alternative? Answer Why is that? Does it mean that we shouldn’t implement observer pattern anymore? Answering the latter part first – YES, it does mean you shouldn’t implement