Observer Pattern - Design Patterns (ep 2)
HTML-код
- Опубликовано: 31 янв 2017
- Video series on Design Patterns for Object Oriented Languages. This time we look at Observer Pattern.
► The playlist
• Design Patterns in Obj...
► Head First: Design Patterns
geni.us/nlbA6
► Design Patterns: Elements of Reusable Object-Oriented Software
geni.us/PsXmo
💪 Patreon Community
/ christopherokhravi
📚 Products I Recommend
geni.us/71ZXF
Because of the good content, I subscribed and clicked the bell to become an observer of your channel. Now whenever you post a new video, i'll be notified! Thank you for this series!
hahahaha best com!
Sir I too am now an Observer. Usually I go to Udemy for my design pattern refreshers but this time I thought hey why not give the RUclips algorithm a chance since it's so good with providing me with physics and nature learning videos. But as a programmer I never used youtube as my go to for learning. Usually it's just stackoverflow or Udemy. But seeing this channel just blew me away. It's like Christopher is speaking to my ADHD soul and saying ..."hey, I got you bro". Well thank you sir!
OK NOW, can we make this a thing -where if you're simply amazed by the effort Christopher is taking to explain this to us as if we're his own... to at least semi reciprocate -Isn't the least we can do is become an observer to his channel?!!
- IF YOU CLICKED ON THE BELL TO BECOME AN OBSERVER THEN LIKE AND REPLY TO THIS COMMENT!
thank you. Peace, my fellow homo sapiens. Stay true.
Instablaster.
@@h4hashir My ADHD soul got distracted by the comments sections, but I am loving his channel and am also an observer
good one xD
Kind of reminds me of a dad driving with the kids in the back repeatedly asking "Are we there yet?". Dad would be more happy if they stay quiet and he just updates the kids upon arrival or pit stops along the route.
This is like Vsauce for programmers. Great explanations!
Perfect! kkkkkk
man if my school had teachers like this, I would never ever skip a class. So fun and interesting to watch
you are a very good Instructor , good job :)
mohamed magdy thank you for the kind words!
mohamed magdy z
agreed!
Yes, I think so too! Much better than my uni Professor. I actually enjoy listening to these videos
I'm just putting a comment here to encourage you to make more videos :) Keep up the good work.
+VIVEK VERMA appreciated. Thanks for taking the time and thanks for watching :)
Never did I understood a concept so easily, the rythm, the cuts, the words, the real life example, everything was perfect! THANK YOU!
2020 and still one of those best explanations about design patterns.
Great work!
2021 same :)
@@arthurfedotiew3609 2022 also same.
2023 baby
@@sharkman4448 Still the same
2023 same
It certainly shows that you have a lot of passion for the subject. That's what makes a good teacher - being energetic and excited about certain topics makes your students energized and excited as well. Great job!
By far the most effective lessons on design pattern, I am going through your entire series. Thank you!
Awesome! Your playlist is gold. Thanks for making it freely available to all on RUclips.
The most wonderful instructor i've seen in my entire lifetime
TINGGGG! You've got an Observer
You've kinda injected it into my mind. Amazing stuff.
Awesome job, Chris! Saves time to read 50 pages :) I've watched your other pattern videos and they are also great! Thank you, Chris :)
Thanks, @Christopher Okhravi. The more I watch your series the more I fall in love with the Design patterns.
One of the best videos on Design Pattern on internet, Great work !
Probably the most frustrating thing about learning something online (either from RUclips or through MOOC) is the fact a given content is explained once and in one way only. If you can't ask, if as a student you cannot ask questions for clarification about a given detail, most of the time you get stuck and you need to find the information elsewhere. Your video is a great example of how repetition and rephrasing can solve this problem. Thanks a lot.
yep, I also really liked the carefully chosen words. Words have meaning (duh!) and tech industry (from schools to books to companies) is extremely lenient when it comes to those meanings. Subject can mean the data inside the observeable, therefore it is not a good choice for observeable.
Absolutely fantastic video! People like you are what gets us through Computer Science. You have my utmost gratitude!
Respect for the fact that you really want to make sure that we get the concept. A true contributor for the community.
This might have been the best description of both definitions and also pseudo i've ever seen. period.
You handle the topic so easily, and makes it very easy to understand as you go through!
Thank you so much for the enlightenment!
This seems like the most underrated youtube channel ever
Christopher, you are the master of explanation! Your editing style with cutting all redundant pauses, etc. is superb! The way you explain things is also very nice. Please continue your project, it's very useful!
Your explanation is so clear and straight to the point, great job 👏
This is by far one of the best design patterns playlist i have seen.
These videos are incredible. Thank you so much for making them. I really do feel like I understand these design patterns in a way that I didn't before.
James Coker fantastic! I'm so glad. Thanks for letting me know :)
I am self teaching myself to try and break into the tech industry. Having you almost feels like I have a professor to lecture the material to supplement my reading and practice. Thank you for doing this. On to the Decorator chapter!
This is truly amazing. Very good job while explaining design patterns. I found myself here watching this video in a middle of the Friday night because it is so interesting, easy going and even entertaining!!!
Your videos has a very simple and genius explanations. Congratulations! This is the best overview I ever read about design patterns.
You make learning so much fun! Thank you! Absolutely love these videos.
Thank you! That makes me very glad to hear. I appreciate you taking the time to share it :D Thanks for watching :)
@@ChristopherOkhravi you are so good instructor, thank you for these free tutorials
Hey Christopher,
First, thanks a lot for the valuable information but also for your natural and nice way to breaking down abstract notions to make them more concrete.
Being an intermerdiate Architect/developper, I find your "code walks" very "friendly" too, answering many of daily dilemmas, and helping to think in a larger and better way.
The design patterns videos are quiete long, but EVERY minute is worth watching!
Please keep inlightening us (y)
anasfcb thank you very much for the utterly kind words. I'm very glad that the content is useful. I consider myself intermediate as well but tend to talk a lot about what I think about :) :)
Your tutorials have helped me a lots in my study. I hope you keep on doing helpful videos like this. Thank you so much
Omg, this is the best observer pattern lesson in the world!
You've spelled everything out for us so clearly. Thank you!
Dude these are SO GOOD. Thank you for this content. Currently studying for upcoming FAANG interviews and I like to cap off my study sessions with a video or two of yours because they are just so good and entertaining that I can still pay attention and soak in that much more. Cheers!
Hi,
How was the interview experience ? Did you get in ? Me on the same path. 😑
Cool, I like it. Your energetical didn't give me to sleep otherwise wen I read this book and watch other videos it was boring , Thank you bro =)
Thanks! I'm glad :) Thanks for the comment.
Kudos to you! All of your videos break down difficult topics into easily understandable explanations! Keep doing the good work
@Christopher ... great explanation, it clearly shows how much effort you have put into this. Thanks a lot for giving back to the community. I hope everyone gets inspired by you and keep sharing knowledge.
Dude your explanations are super clear and understandable. This design course is better than a lot of pay courses Online. Thanks a lot!!!!!
Thank you for the very kind words. Humbling. 🙏🙏
Real life Poll example: Toddler asking every ms "Mommy, can I have a chocolate" ...
🤣🤣🤣
these video's are more usable than my entire semester of design. we use the same book as you do, but you explain it like 20 times better :)
This is so great!! Thank you tons! You deserve the world, this is the best video series on design patterns in the whole world!! Finally i understand these concepts!
Hello Christopher, very interesting and very clear how you explained the observer pattern. I just subscribed to your channel because I am interesting in this design pattern series.
By the way, Robert Martin (Uncle Bob) talks about the Single Responsibility Principle violation in the observer pattern, but if i remember correctly, it is part of the trade off you have in order to use the pattern, on the other Hand, remember that the SOLID principles are more like guidelines than some kind of laws, some of them bend, some of them can be broken.
Rafael Heredia Bastidas Thanks for the comment! I'm glad it's useful. And thanks for bringing the words of Bob Martin into the conversation! Makes sense.
Here's a couple of improvements I would make to this. In order to satisfy the Single Responsibility Principle, I would create a WeatherStationObservable class that implements IObservable and use composition to have an instance of WeatherStationObservable inside the WeatherStation class. This way, WeatherStation will only have the responsibility of dealing with temperatures, pressures and other weather related things. The second thing I would do is make WeatherStation implement an interface IWeatherStation, this way I can inject an IWeatherStation into PhoneDisplay so that it doesn't rely on the concretion WeatherStation.
why do you need extra WeatherStationObservable class, why cant WeatherStation class implement IObservable and IWeatherStation and this will be injected to PhoneDisplay so that it only worries abt getTemp instead of having access to registry.
Single Responsibility Principle: A class should only serve one purpose in your code. By breaking it up, your code becomes more modular, reusable, and less likely to break during later refactoring.
Yes please! This is great for all of us who needs to hear things 3 times to get it!
I bought this book years ago and just never really had the time or interest to get into it and now I'm really glad that I did and I'm so glad that I found your videos because they make this book so much more enjoyable thank you so much
Thank you soo much. These are very helpful. Eagerly waiting for the next one :)
Thanks. I'm glad it makes sense :)
Really great explanations
Thanks. I'm glad to hear it works :) Thank you for watching :)
The best explanation of the observer pattern I've ever seen. Thanks 👍
I cannot stress how great Teacher you are.
NOTES: An observable has many observers. Push model/Broadcasting/chatting system can be implemented using observer pattern. Chatroom is an observable, user is observer.
you're the best, seriously :dd.
You are probably the best instructor on youtube. Thanks for the vid.
2022 and still one of those best explanations about design patterns.
Great work! hopefully you still active and post more videos about anything
if only it was possible to click like more than once, great vidéo (y)
You having commented on multiple videos is perhaps even better :) But I'm humbled, and I thank you :) If you know someone who might be interested in the video, do feel free to share it with them.
Also the (y) has to count for something right? Qualitative thumbs instead of quantitative :)
every programming tutorial should be done like this :)
The clearest explanation about this topic I've ever heard, thank you!
Love your videos. I tried to learn pattern so many time before and just now (with your videos) I'm finally understanding them. Thank you so much
Great job man! I would like to suggest that one inconvenient of passing the Observable reference in the Observer constructor is when an object is Observer from more than one Observable. In the example, imagine that the display needs to show not only data from the WeatherStation, but also from a RealtimeClock. One solution can be to include the reference in the Update() function.
All devs should know these patterns. Great work! Better than watching someone type ;) Just a quick note, this could of been a lot shorter. Laboured the point some times. Appreciate your enthusiasm and effort though 👍🏻
+Adrian Collins Thank you for the detailed feedback. Much appreciated. It's super easy to accidentally get repetitive but point well taken and I'll try harder! Thanks for watching and for sharing :)
Well, as a dev I know the patterns but having to deal with legacy code bases, getting into what's going on in there (because developer's didn't document, the 2nd/3rd generation of developers is on the project, ...) and with very little time on my hands there's simply no way I could apply all of them. No one pays me for heavy refactorings. If you have the time to design a new program, design it well and DOCUMENT it :)
I find it hard to focus on things like this, so i appreciate the repetition
@@ChristopherOkhravi I like the repetition. It basically reinforces our understanding without having to seek the video multiple times and losing the momentum.
I am so glad I found you, you are the teacher I always wanted since primary school
Crystal clear explaination! Thanks a ton for this wonderful video explaining the design pattern in great depth.
mmmm, I still don't like the idea of passing the observable to the observers as parameter into the constructor of the observers. feels like you are giving the observers more than they need to know the data!
I think it would be better to send the updated data via update(newData) method..
- consider the following use case:-
* At the same concrete class "weather station", they are more than one senser.. for wind speed, another for humidity, and of course the one for temprture..
* Now Imagin that there're some observers which are interested only in the humidity, and others in wind speed only..
we can do an observer pattern for each piece of data by itself, with the update method signature changed based on the wanted data..
* so we can have update (Humidity newHumidityData), update (WindSpeed newWindSpeed), etc .. each one into its own observer interface of course..
* what I'm saying is, you observe pieces of data, not the whole object :) .. that way I prefer passing the new data via update :) ..
I really like your vids, don't stop, keep moving forward :)
----------------------------------------------
Edit: I wrote my comment before finishing the vid :D , my bad there.. I liked that you touched on the subject at the end :)
I agree 100% with your comment. Great example. Thanks for sharing it! :D
I also have the same concern. Instead of creating interfaces for different signatures of update method, we should create a generic interface that has void Update(T value) and IObservable with void Add(IObservable observer).
+1 Excellent idea! Can't see why I didn't think of that :) :) Thanks for sharing!!
.NET has their own battle tested APIs for this that takes generics. Pretty sweet!
msdn.microsoft.com/en-us/library/dd990377(v=vs.110).aspx
Makes more sense to send the instance and/or data in the update() method itself, as said at the end...
really good tutorial :)
Thanks!! :)
Thank you so much, I could never quite figure out how it works exactly but now I understand it and was able to implement it. You're a very good instructor, I like how you use visual examples. Keep going!
This is THE best design pattern tutorial I've ever seen
Thanks again for this new video! it was well explained. Bur I got a question. Could we have passed an interface as argument of ConcreteObserver constuctor? so we would be able to pass any kind of ConcreteObservable, maybe a WeatherStation or Something else which can produce Data?
Good question. Absolutely. The key question is of course what the signature of the GetData() method in the Observable is. As long as the Observables you want to be able to observe with your ConcreteObserver has the same signature for the GetData() method (regardless of whether it happens to be named GetData or not) I completely agree with your idea.
In other words, let's say that we have two ConcreteObservables: ModernWeatherStation and ClassicWeatherStation. Let's say that both inherit from IObservable. If I'm not misunderstanding you, you're suggesting that we let both of these implement the same interface, let's call it IWeatherStation. Because then we can let the ConcreteObservable accept an instance of an IWeatherStation in the constructor instead of a concrete weather station like ModernWeatherStation.
This increases abstraction and I'm 100% with you. It's in my mind a good idea.
Thanks for watching!
konzinov maverick just to note maybe it would be better to have generics instead of an iweatherstation or a generic that implements iweatherstation but this all depends on language and situation
+Misha +1. Agreed.
I'm not sure I follow but do you mean to allow the IWeatherStation to be passed as an argument to the constructor of the ConcreteObserver (and not ConcreteObservable)?
for this case ,shouldn't we have to add getStatus() method inside interface ?
42:15 left down corner :)
Hah! I had not seen it :D
ruclips.net/video/KkF8-vhVM_0/видео.html
After working in another job for roughly 10 years, I am trying to get back into software development and currently studying up for interviews. This is immensely helpful and you are a great instructor! Thanks for this!
This series is helping so much. I read the chapter then I watch your presentation. I will repeat that for each chapter/video. Then in the Fall, I am enrolled in an actual course at the local Tech college. Repeat again but then with actual assignments, tests grades all that.
I'm supposed to learn for a microeconomics exam that's in two days from now but this stuff is way too captivating lol
+Andrei Florea hahaha :D Well, at least you're procrastinating with something that might have a high payback still :) Best of luck on the exam and thanks for watching!
I guess you forgot " station.add(this); " in the constructor of the displayer.
dude you are awesome, this is like literally a complete walkthrough the whole design flow, i'm already on 37:28 and i completely understand what's the observable flow and what's the difference of when we have a reference to observable in observer and when we don't have, thanks man
The Best instructor in youtube, thanks for your time.
This is the best video I could find on this design pattern. Thank you!
Thanks man, you are sharing great tutorials for free, may god bless you !!!
Great explanations, concise yet to the point!
your explanation is really beyond description...i'd love to get notified more often of your video...
Fact that most of the people came down to put a comment shows that they sincerely appreciate your content. It definitely deserves more views. This channel worth subbing 💜
You are the best Instructor... Love the way you explain the analogy.
Thanks for the series.
The best tutorial ever, you easily explained the hard stuffs
Thank you, thank you, thank you! I wish my university teacher could teach like you!!! Don't stop doing it that way.
Brilliant explained. Best online teacher I have ever seen. The way you explain is so understandable :-)
I love your english! You are giving yourself teaching by emphaty. Brilliant !
The best explanation I've found so far. I mean yes I need to hear the same thing for a lot of time to catch in my memory regardless the duration of the video. Enjoying the learning!
the best video on observer pattern on the internet... good job !!!
What an amazing teacher you are!
you are an amazing teacher -- very engaging! thank you sooo much for posting these
Boss you are good the way you simplify it removing the confusing terms is nice
What fun to watch your videos.
You are funny, human, and free.
And most importantly know how to explain in the clearest way.
Going through the HFDP book right now, this is a great companion to it. thanks!
Great video serie. I bought a book about Design Patterns but with your explanation is makes much more sense. Keep up the good work.
Best design pattern explanitaion ive found on RUclips and better than any ive found on Udemy. Definetly appreciate this series!
I never ever thought that design patterns are this much easy to understand. All concepts are explained so well in this series. Thank you so much. Best regards.
I have watched two of your videos so far, and i must say that you are an excellent teacher! 10/10.
This is the best explanation of design patterns! Thank you, man!
school need teachers like you , great job
You are really genius sir, I have been looking for such videos since long. Thank you so much for putting all these videos and learning in simplified way, bunch of bunch of thanks to you.
Very nicely and precisely compiled videos. You are a very good instructor with lot of energy and thorough understanding of the topic, so please continuing doing the same. Much appreciated
Simply Fantastic. Best Explanation so Far.
Very good, concise and clear. Excellent teacher.
I don't usually comment on videos, but you're an incredible instructor. Thank you, please keep up the great work. Subscribed.
Wow! Awesome! I really appreciate your effort. This is the exact explanation I need. Funny thing is no one is talking about this, it's syntax here and there. Thanks for closing the gap, it a big difference.