Observer Pattern - Design Patterns (ep 2)
Vložit
- čas přidán 31. 01. 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 CZcams 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!
Probably the most frustrating thing about learning something online (either from CZcams 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.
This seems like the most underrated youtube channel ever
Absolutely fantastic video! People like you are what gets us through Computer Science. You have my utmost gratitude!
By far the most effective lessons on design pattern, I am going through your entire series. Thank you!
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. 🙏🙏
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!
you're the best, seriously :dd.
TINGGGG! You've got an Observer
You've kinda injected it into my mind. Amazing stuff.
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 :) :)
Thanks, @Christopher Okhravi. The more I watch your series the more I fall in love with the Design patterns.
Awesome! Your playlist is gold. Thanks for making it freely available to all on CZcams.
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 :)
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!
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!
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.
Awesome job, Chris! Saves time to read 50 pages :) I've watched your other pattern videos and they are also great! Thank you, Chris :)
Omg, this is the best observer pattern lesson in the world!
You've spelled everything out for us so clearly. Thank you!
The most wonderful instructor i've seen in my entire lifetime
Real life Poll example: Toddler asking every ms "Mommy, can I have a chocolate" ...
🤣🤣🤣
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
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!
2023 and still one of those best explanations about design patterns.Thank you Christopher ❤
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. 😑
Really great explanations
Thanks. I'm glad to hear it works :) Thank you for watching :)
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 for the detailed explanation. I like how you go into every single detail and almost always answer the questions that sprang to my mind on the spot. Everything clicks after watching the video. You deserve more subscribers.
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.
Thank you soo much. These are very helpful. Eagerly waiting for the next one :)
Thanks. I'm glad it makes sense :)
@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.
You're making everything clear to me, thank you!
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.
There is no point in creating extra IWeatherStation interface and using it in phonedisplay. You are still coupling WeatherStation to phone display because IWeatherStation will only be implemented by WeatherStation.
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 :)
What fun to watch your videos.
You are funny, human, and free.
And most importantly know how to explain in the clearest way.
Thank you, thank you, thank you! I wish my university teacher could teach like you!!! Don't stop doing it that way.
really good tutorial :)
Thanks!! :)
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.
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
2022 and still one of those best explanations about design patterns.
Great work! hopefully you still active and post more videos about anything
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...
every programming tutorial should be done like this :)
The first Design Patterns Series that really simplifies and doesn't overcomplicates the basics! You're the best, keep up with the channel please!
Simply Fantastic. Best Explanation so Far.
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.
NOTES: An observable has many observers. Push model/Broadcasting/chatting system can be implemented using observer pattern. Chatroom is an observable, user is observer.
One of the best videos on Design Pattern on internet, Great work !
The clearest explanation about this topic I've ever heard, thank you!
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!
42:15 left down corner :)
Hah! I had not seen it :D
czcams.com/video/KkF8-vhVM_0/video.html
Your style of explaining a topic is so intuitive that things automatically unfold and make sense at the right time. Truly appreciate the efforts you put into making such informative videos.
Thank you from India ❤️
Great explanations, concise yet to the point!
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 ?
I guess you forgot " station.add(this); " in the constructor of the displayer.
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!
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!
This is by far one of the best design patterns playlist i have seen.
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!!!
THIS IS THE BEST EXPLANATION I HAVE SEEN SO FAR! My lecture in uni just made a ten minutes power point slide to explain this and i understand no shit except using a magical interface called observer can reduce coupling. The explanation you made makes total sense, you have done such a great job on keep repeating and emphasising your points and used some great examples for looking in the insights. Thank you so much :D I have learned a lot and it's fun watching it! Keep on the good work!
Best tutorial I’ve ever seen. Insane! 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
Yes please! This is great for all of us who needs to hear things 3 times to get it!
OMG Man! You are best programming teacher on youtube! Thank you for your videos!
You are probably the best instructor on youtube. Thanks for the vid.
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 :)
Pure Majic in Explanation !! Didn't realise the time while watching it and it seems like just now started.Thankyou for such good content!
Kudos to you! All of your videos break down difficult topics into easily understandable explanations! Keep doing the good work
I cannot stress how great Teacher you are.
I have watched two of your videos so far, and i must say that you are an excellent teacher! 10/10.
The Best instructor in youtube, thanks for your time.
What an amazing teacher you are!
your explanation is really beyond description...i'd love to get notified more often of your video...
one of the best Instructor. really great job.
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.
This is the best video I could find on this design pattern. Thank you!
Your tutorials have helped me a lots in my study. I hope you keep on doing helpful videos like this. Thank you so much
This waas super helpfull, I've never been that excited to watch a video from start to finish. You're awsome, keep it up :)
Very nicely researched, complete and thorough explanations. Thank you!
You are the best Instructor... Love the way you explain the analogy.
Thanks for the series.
Crystal clear explaination! Thanks a ton for this wonderful video explaining the design pattern in great depth.
dude you are on fire. thanks for being a great teacher!!!
Your videos has a very simple and genius explanations. Congratulations! This is the best overview I ever read about design patterns.
the best video on observer pattern on the internet... good job !!!
I am so glad I found you, you are the teacher I always wanted since primary school
Very great detailed explanation. No questions must be left from viewers.
Best design pattern explanitaion ive found on CZcams and better than any ive found on Udemy. Definetly appreciate this series!
This is THE best design pattern tutorial I've ever seen
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!
The best tutorial ever, you easily explained the hard stuffs
I'm highly enjoying your video series! Will check out what other stuff you got because you explain everything so smoothly!
Your explanation is so clear and straight to the point, great job 👏