Observer PatternAn Observer Pattern says that "just define a one-to-one dependency so that when one object changes state, all its dependents are notified and updated automatically". The observer pattern is also known as Dependents or Publish-Subscribe. Benefits:
Usage:
UML for Observer Pattern:Implementation of Observer PatternStep 1: Create a ResponseHandler1 class the will implement the java.util.Observer interface. Step 2: Create a ResponseHandler2 class the will implement the java.util.Observer interface. Step 3: Create an EventSource class that will extend the java.util.Observable class . Output: Next Topicstate Design Pattern |