Actually as per the GOF, the update method does not take any parameter, instead we get the state(location) from the subject itself by calling subject.getLocation() in the update(). And obviously subject would be as member variable in observer in order to get the state. Also, when you would pass the subject in the constructor of observer, you would call the subject.register(this) in order to register the observer. After watching a lot of videos on this pattern, I got to know about it, like how it is written properly.
well, think about it, since an observer has the object of the subject(the implementation of subject), any observer (mistakenly or intentionally)may call update through the object, and all the observer may get wrong information. What you say is correct as per GoF, but I have found this implementation better. GoF gives you an outline you can always improve that. I am not an expert. just curious.
Thank you for the explanation, however I have a doubt. How will we be able to implement if the user wants to know the current location of the "article", if they have not registered? Basically how can they request themselves for the data, instead of being pushed the data? Thanks in advance, nice explanation.
Thanks. Sorry for late reply. Somehow i missed it. Observer Design pattern is used only for Notification system. To implement your case, we can have a another API, where we can call GET request, which'll give me all required attributes of article, i.e location, name, title, etc. Let me know if you've any further question on it.
Just want to say one thing Spring framework has ApplicationEventListners which is designed using this pattern. If you can explain how does spring did that things will be too easy....for viewers. Thanks.
watching it now, and its still very good compare to other tutorials. great work @Coding Simplified.
Lucid and very easy to understand. Thank you bro
Thanks for your nice feedback. Keep Watching.
You have an easy way to explain, thanks.
Thanks for your nice feedback. Keep Watching
❤liked your explanation. Thanks
Thanks a lot
Thanks for your nice feedback. Keep Watching :)
Actually as per the GOF, the update method does not take any parameter, instead we get the state(location) from the subject itself by calling subject.getLocation() in the update(). And obviously subject would be as member variable in observer in order to get the state.
Also, when you would pass the subject in the constructor of observer, you would call the subject.register(this) in order to register the observer.
After watching a lot of videos on this pattern, I got to know about it, like how it is written properly.
well, think about it, since an observer has the object of the subject(the implementation of subject), any observer (mistakenly or intentionally)may call update through the object, and all the observer may get wrong information. What you say is correct as per GoF, but I have found this implementation better. GoF gives you an outline you can always improve that. I am not an expert. just curious.
@sushil yadav
Excellent !!!!!
Thanks for your nice feedback. Keep Watching.
Thank you
Thanks for your nice feedback. Keep Watching.
Awesome 👍
Thanks for your nice feedback. Keep Watching.
Thank you for the explanation, however I have a doubt. How will we be able to implement if the user wants to know the current location of the "article", if they have not registered? Basically how can they request themselves for the data, instead of being pushed the data? Thanks in advance, nice explanation.
Thanks. Sorry for late reply. Somehow i missed it. Observer Design pattern is used only for Notification system. To implement your case, we can have a another API, where we can call GET request, which'll give me all required attributes of article, i.e location, name, title, etc.
Let me know if you've any further question on it.
@@CodingSimplified Thank you so much, makes sense, my question was beyond the scope of the Observer pattern. keep up the good work.
Just want to say one thing Spring framework has ApplicationEventListners which is designed using this pattern. If you can explain how does spring did that things will be too easy....for viewers. Thanks.