Observer Pattern - Design Patterns (ep 2)
Вставка
- Опубліковано 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 UA-cam 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
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
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 :)
man if my school had teachers like this, I would never ever skip a class. So fun and interesting to watch
Never did I understood a concept so easily, the rythm, the cuts, the words, the real life example, everything was perfect! THANK YOU!
This seems like the most underrated youtube channel ever
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 UA-cam 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.
By far the most effective lessons on design pattern, I am going through your entire series. Thank you!
TINGGGG! You've got an Observer
You've kinda injected it into my mind. Amazing stuff.
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!
Awesome! Your playlist is gold. Thanks for making it freely available to all on UA-cam.
Thanks, @Christopher Okhravi. The more I watch your series the more I fall in love with the Design patterns.
Real life Poll example: Toddler asking every ms "Mommy, can I have a chocolate" ...
🤣🤣🤣
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 :)
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!
2023 and still one of those best explanations about design patterns.Thank you Christopher ❤
Absolutely fantastic video! People like you are what gets us through Computer Science. You have my utmost gratitude!
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.
2022 and still one of those best explanations about design patterns.
Great work! hopefully you still active and post more videos about anything
Awesome job, Chris! Saves time to read 50 pages :) I've watched your other pattern videos and they are also great! Thank you, Chris :)
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. 🙏🙏
The most wonderful instructor i've seen in my entire lifetime
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
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 :) :)
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
Omg, this is the best observer pattern lesson in the world!
You've spelled everything out for us so clearly. Thank you!
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!
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.
Going through the HFDP book right now, this is a great companion to it. thanks!
Thank you, thank you, thank you! I wish my university teacher could teach like you!!! Don't stop doing it that way.
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.
Really great explanations
Thanks. I'm glad to hear it works :) Thank you for watching :)
You're making everything clear to me, thank you!
Yes please! This is great for all of us who needs to hear things 3 times to get it!
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.
Thank you soo much. These are very helpful. Eagerly waiting for the next one :)
Thanks. I'm glad it makes sense :)
One of the best videos on Design Pattern on internet, Great 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.
you're the best, seriously :dd.
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 :)
your explanation is really beyond description...i'd love to get notified more often of your video...
Your tutorials have helped me a lots in my study. I hope you keep on doing helpful videos like this. Thank you so much
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!! :)
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 by far one of the best design patterns playlist i have seen.
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.
every programming tutorial should be done like this :)
I cannot stress how great Teacher you are.
This is THE best design pattern tutorial I've ever seen
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.
42:15 left down corner :)
Hah! I had not seen it :D
ua-cam.com/video/KkF8-vhVM_0/v-deo.html
Great explanations, concise yet to the point!
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
NOTES: An observable has many observers. Push model/Broadcasting/chatting system can be implemented using observer pattern. Chatroom is an observable, user is observer.
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 ?
What fun to watch your videos.
You are funny, human, and free.
And most importantly know how to explain in the clearest way.
Your explanation is so clear and straight to the point, great job 👏
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.
The clearest explanation about this topic I've ever heard, thank you!
Your videos has a very simple and genius explanations. Congratulations! This is the best overview I ever read about design patterns.
Christopher Okhravi
Your explanations are good, but this particular video is difficult to watch because of the dropped frames. Can you please change your video editing style so that there are no jumps from one video frame to another. I guess you are trying to make your video to look cool, but in fact you just made it hard to watch.
I'm sorry the format isn't working for you. The "harsh" cutting is used because I want to be respectful of your time as a viewer. If I was able to get it right every time on every take then I wouldn't need the cutting :) I'm not that good yet but will hopefully become in the future :) Thanks for watching.
Christopher Okhravi and this really helps.. consise and fast.. removing the extra time writing and erasing the board... Saves a lot of time and patience too 🙂
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 ❤️
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!!!
Kudos to you! All of your videos break down difficult topics into easily understandable explanations! Keep doing the good work
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
Thank you a lot! I'm preparing for the Middle position and I've got stuck in this patterns topic for a few days already😅. And now I need only one evening to watch your lectures and understand all this stuff ❤️
I am so glad I found you, you are the teacher I always wanted since primary school
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.
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!
The best explanation of the observer pattern I've ever seen. 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!
You are probably the best instructor on youtube. Thanks for the vid.
Headfirst design patterns is a great book! I've recommended it to dozens of people I've worked with and people I've interviewed who had never heard of design patterns.
Years ago, I read one of the original books on design patterns and understood the ideas, but I didn't get the why of it all. Years later, I picked up Headfirst, and suddenly, it all made sense. My favorite design pattern is the state machine. I've found so many places in my designs where it simplified what would otherwise end up being hundreds of lines of nested case and if/then/else statements into small, trivially testable, pieces of code. Much of it containing no control statements at all.
I could not recommend this book more!!!
Thanks for sharing this. I think you are very right in that it is a tremendously useful book for introducing the topic of patterns in an approachable manner. Thanks for watching 😊
Thank you for this. I'm down two videos. Strategy and Observer. Awesome content.
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.
What an amazing teacher you are!
Crystal clear explaination! Thanks a ton for this wonderful video explaining the design pattern in great depth.
This is the best explanation of design patterns! Thank you, man!
This is the best video I could find on this design pattern. Thank you!
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!
I'm highly enjoying your video series! Will check out what other stuff you got because you explain everything so smoothly!
school need teachers like you , great job
Your way of teaching is awesome!!
Great video serie. I bought a book about Design Patterns but with your explanation is makes much more sense. Keep up the good work.
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 were very clear and not at all confusing. Thanks!
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.
Very helpful, rare to find these good teachers.
Good because, on subject, concise.
And I have to describe it as you kind of re-iterate over every step, you explain the most important thing at the start.
Then we are reminded everytime when you reuse that step, becuase you explain it briefly or how it is used this time.
Great job bro, honestly
The best tutorial ever, you easily explained the hard stuffs
What a great, clear and concise explanation!
Best design pattern explanitaion ive found on UA-cam and better than any ive found on Udemy. Definetly appreciate this series!
Best tutorial I’ve ever seen. Insane! Thank you