java pp(5)

Views:
 
Category: Entertainment
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE :

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE https://www.besanttechnologies.com/training-courses/java-training

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE :

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE Java is a fundamental fundamental Java standard in which the Observer observes any change in the state or ownership of the Subject. For example, the company updates all its shareholders for any decision they make here. The company is object and the shareholders are observers, any change in the policy of the company and the Company notifies all its shareholders or observers.

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE :

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE This was a simple explanation of the real world of the Observer pattern. In this article, we will detail what is the Observer Design pattern, what is the benefit of the observer design pattern, example pattern or observer in Java and some other points. As well as the decorator design pattern and the factory pattern in Java , the observer pattern is also used in the JDK. Java pattern example of the observer design pattern: What is the observer design pattern? Observer in Java code ExampleThe pattern of observer design in Java is a very important pattern and, as the name suggests, is used to observe things.

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE :

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE Suppose you want to notify the change in a particular object that observe this object and Changes will be notified to you. The object that is being observed is referenced as Subject and the classes that observe the subject are called Observer. This is a beautiful standard and is used intensively together with the Model View Controller Design standard,

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE :

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE in which the model change is propagated for the visualization, so you can render with modified information. Observer pattern is also a very popular Java interview question and mainly asked at the upper or upper middle level. Problem that is solved by the Observer Pattern: If we have the requirement that yes a specific object change its state and depend on This changes some or the group of objects automatically change their state, we need to implement observer pattern that will reduce the coupling between objects.

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE :

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE In the real world, if you try to find an example, see when we sign a new phone connection whenever the customer registers with this company, all other departments are notified and, depending on the status of the verification, verification of the address is check, then send the welcome kit, etc.

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE :

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE As the pattern design pattern is implemented in Java; For the implementation of this standard, the java makes our task very easy, the developer does not need to do much to implement this pattern. In the java.util package, we can find interfaces, classes and methods to implement this standard.

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE :

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE Public interface service: Any class that implements this interface must be notified when the subject or observable object changes its status . Update (Ob Observable, Object arg ): This method is called when the subject is changed. Observable class: It is a subject to whom the observer wants to observe.

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE :

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE The other method Important: addObserver (Observer or): add observers in the set of observers to this object or object obserlbel.deleteObserver (Observer o): exclude observers in the set of observers.hasChanged (): check if the object has changed. clea rChanged (): this method will indicate that the subject has not changed or that all observers have been notified when changes are made . notifyObservers (): notifies all observers if the object has changed. Design pattern observer Java: The main advantage is the low coupling between objects called observer and observable.

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE :

OBSERVER DESIGN PATTERN IN JAVA WITH REAL WORLD CODE The disadvantage is that, at some point, if any problem occurs, debugging becomes very difficult because the flow of control is implicitly between observers and observables, we can predict that now the observer will fire and if there is a chain between observers, the debugger it becomes more complex. Another issue is memory management, since the subject will contain all the reference of all the observers, if we do not cancel the record of the object that can create the memory problem. This is all in the Observer Pattern in Java. Share your thoughts on how and when you used the Observer Pattern in your project and any problems you have faced?

authorStream Live Help