Null Object Pattern - Design Patterns (ep 18)

  Рет қаралды 61,518

Christopher Okhravi

Christopher Okhravi

6 жыл бұрын

Video series on Design Patterns for Object Oriented Languages. This time we look at the Null Object 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
► Sandi Metz - Nothing is Something
• RailsConf 2015 - Nothi...
💪 Patreon Community
/ christopherokhravi
📚 Products I Recommend
geni.us/71ZXF

Пікірлер: 177
@piyushajmani5
@piyushajmani5 5 жыл бұрын
Where'd you go? I miss you so. Please continue the series.
@renatoinnocenti
@renatoinnocenti 6 жыл бұрын
Continue this series please!
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
If all goes well I’ll start dropping episodes again within a month :) Thank you for the patience :) :) And your enthusiasm :)
@takssir
@takssir 5 жыл бұрын
@@ChristopherOkhravi hi, do you have any new?
@samueljames7071
@samueljames7071 5 жыл бұрын
@@ChristopherOkhravi yes please can you cover the MVC pattern!
@fadybichara
@fadybichara 5 жыл бұрын
Hey Chris .. this is very helpful .. I Wish you can continue this amazing series
@victorbrylew1775
@victorbrylew1775 5 жыл бұрын
Next episode of this series is NoEpisode. Just handle it correctly!
@sayantansengupta9939
@sayantansengupta9939 3 жыл бұрын
It is sad that you stopped this series. Watched all your videos last year and really loved all of them. Coming back in 2021 with the hope that you may have uploaded new videos.
@professorfontanez
@professorfontanez 4 жыл бұрын
The first time I heard of this pattern, I dismissed it immediately as dumb. Then I took the time to examine it and it literally changed my life. It is now my favorite pattern. The simplicity is genius and it makes your code some much better and cleaner. I recently implemented (within the last year or so) a small framework where I received models from an XML file as (JAXB) objects. I replaced nulls with Null Objects to avoid situations such as the wrong name or ID is pass and a valid model could not be found. So instead, my framework simply returns a null object and the system would not break because my null object obviously respects the interface. Fast forward to about a month ago. I needed to integrate this framework to interact with a legacy system that doesn't generate these models. I was able to seamlessly do it because, now my null object is used to represent the "model" of the legacy system. In order words, the legacy system has NO MODEL; which is precisely what the null object represents. This is why this changed my life. That decision around 12 months ago to put this concept in practice, even though I "didn't needed it" saved me weeks or perhaps months of additional implementation. I was able to integrate this legacy system in a couple of days.
@ChristopherOkhravi
@ChristopherOkhravi 4 жыл бұрын
The excellent and vivid examples that you’re scattering over the comment sections truly improve the value of this KZbin channel so let me just pause and say: thank you! Great examples 😊😊
@professorfontanez
@professorfontanez 4 жыл бұрын
@@ChristopherOkhravi Thank you Chris. I am actually about to sit down and write about this pattern in my blog and am going to refer to this video. And trust me, it is no exaggeration when I said that it changed my life (professionally speaking of course). And one thing I didn't mention is that I wasn't the one who did the integration. Someone else on the team did. All I had to do was explain the concept in one single sentence. Two days later, integration was done.
@ChristopherOkhravi
@ChristopherOkhravi 4 жыл бұрын
@@professorfontanez If you wish, please feel free to post the blog link as a comment here when it's done. In case it gets caught in the spam filter, let me know.
@claudios
@claudios 6 жыл бұрын
This is awkward, I didn't get you anything for Christmas... and here you got me just what I asked for. Thank you!
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
😊
@akshayvenkatesh5372
@akshayvenkatesh5372 6 жыл бұрын
Great stuff! Please please make a video on Visitor pattern.
@TheToeFungi
@TheToeFungi 4 жыл бұрын
What might be quite cool is a git repository with an example of an implementation of the design pattern being explained.
@cliid4355
@cliid4355 3 жыл бұрын
Actually, I made one. github.com/cliid/design_pattern has all of the design patterns mentioned by Chris, and also some cool ones like Memento Pattern, and so forth.
@Brudof
@Brudof 2 жыл бұрын
Loved these videos. I learn much better in this format vs reading on my own. Hope to see you continue this series one day.
@ZaneSelvans
@ZaneSelvans 4 жыл бұрын
This was a really valuable and thoughtful series! I tried to read the Gang of Four book initially and was overwhelmed, but with this as background it's much more accessible. You're a good teacher, I hope you can find the time to return to making videos in the future!
@dennimer
@dennimer Жыл бұрын
Thank you so much Christopher! I hope you will have time and energy to continue this series. It's hard to find even a payed content with such amazing quality!
@omarabdo6403
@omarabdo6403 4 жыл бұрын
What a great journey! I am ETERNALLY grateful! a few weeks ago, when I started this serious I didn't know anything about design patterns but now I've already implemented many of them to my projects and I can feel the huge enhancement of technical excellency that was introduced to me and to my projects in such a short period of time. it was a shock to see this amazing serious ends although there are other patterns to be covered. I really hope you would resume this playlist even though it has been 2 years since this video. much much love and many thanks to you Christopher!
@grayboywilliams
@grayboywilliams 3 жыл бұрын
Thank you so much for this series! It was so helpful. You are still maybe the only person who put in this much work into explaining these patterns and I appreciate that so much.
@meduto9584
@meduto9584 3 жыл бұрын
Please continue Christopher ! This series was amazing !
@alexhelkar
@alexhelkar 5 жыл бұрын
Very talented author and a great playlist! Came across these videos and can’t stop watching. Thank you so much for what you’ve already done. Please continue!
@valkon_
@valkon_ 3 жыл бұрын
You captivated me from the beginning, I could listen you for hours.
@GeneralAssWitness
@GeneralAssWitness 6 жыл бұрын
Happy to see how your channel gets more and more subscribers. When I checked the last time it was 10k, now it’s 13k. We need videos like this
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
Makes me super glad as well 😄😄
@guyr989
@guyr989 4 жыл бұрын
Will you continue with your videos? If it's about the views I can watch them a million times.
@txxie
@txxie 5 жыл бұрын
I really like your videos about design patterns. Continue this series, please!!!
@BlockDemos
@BlockDemos Жыл бұрын
I just finished this series, thank you very much, Christopher.
@martinleeuwangh
@martinleeuwangh 6 жыл бұрын
Thanks, Chris, for another great video. Happy birthday for last week, merry Christmas and a happy new year, too!
@shraddheshbhandari8740
@shraddheshbhandari8740 6 жыл бұрын
The composite pattern NullIterator example was really good and a perfect use case. On another side note, the youtube "Skip Ad" button before a video starts playing can be another good example (that was motivated by your NullCommand discussion). This button can be disabled for like 5 seconds during which the ad cannot be skipped and thus can be represented by the NullCommand concretion during that time interval and then change its state use the SkipCommand concretion.
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
Wow! Excellent example! I hadn’t thought of that :) :) Thanks for sharing :)
@suhastm6696
@suhastm6696 2 жыл бұрын
Thanks for the wonderful series. I have learnt a lot from this design pattern series. Thank you Christopher.
@bragoen
@bragoen 6 жыл бұрын
This pattern is so difficult to make people accept, but it's helped me my whole life. Stumbled upon your playlist this weekend and I think you're doing a great job, I can now point the juniors where I work to your content. After looking it it I also want to give it a try myself for french speakers.
@amitrk23
@amitrk23 4 жыл бұрын
Thanks a ton for all the videos in this series. Understood different design patterns. Great teaching :)
@kclee8998
@kclee8998 5 жыл бұрын
Thank you very much for this series.
@richardnipples7574
@richardnipples7574 6 жыл бұрын
Awesome examples in these last videos; I hope you keep making more at some point or another.
@konzinovmaverick4539
@konzinovmaverick4539 6 жыл бұрын
Great one dude. This made my christmas
@stanislavspatari2960
@stanislavspatari2960 5 жыл бұрын
Great stuff, hope you'll make more series on this topic.
@jeronimocarrizo5855
@jeronimocarrizo5855 5 жыл бұрын
Thank you so much Chris for this amazing video. I love you work! please keep doing that kind of video! I really love it! Thank you so much again!!!!
@SrishtiShukla9911
@SrishtiShukla9911 5 жыл бұрын
Hi @Christopher Okhravi your videos are great.. Kindly continue this series...
@AndrewReeman_RemD
@AndrewReeman_RemD 6 жыл бұрын
Your videos are great! Excellent examples :) Thanks for these. A video on the visitor or flux pattern would be awesome!
@vperaltac
@vperaltac 6 жыл бұрын
Excellent series, I had to learn a lot of patterns in a month and you helped me a freaking lot, this is hands down the best resource on the internet for design patterns. PD : You mentioned the two books so much over the series that now when i see the titles I subconsciously read it with your voice lol. Thank you very much Christopher.
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
Hahahha that is awesome. Serious brain washing :) :) Thank you for watching and I’m glad it was useful :)
@TheMinino123
@TheMinino123 6 жыл бұрын
Thank you so much for all this work. Really appreciated.
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
And thank you for watching :) And for commenting. I’m glad to hear that the content is useful :) Best of luck with your endeavors!
@krozaine
@krozaine 5 жыл бұрын
This is a great series and I have thoroughly learnt a lot! Your presentation is very natural and instinctive to understand. If your ever get time, we would be glad to have more videos on design patterns. There are a few patterns left on sourcemaking.com that weren't covered here. Appreciate your efforts. Thanks a lot!!
@ColorBaII
@ColorBaII 4 жыл бұрын
I like this video much. Good job. I completely dived into the topic.
@Lahiru_Udana
@Lahiru_Udana 5 жыл бұрын
Thank you for this great series
@reyazahmed9320
@reyazahmed9320 6 жыл бұрын
Hey Christopher, thanks for your awesome work. Please make a video on the visitor pattern.
@snigdhav7068
@snigdhav7068 5 жыл бұрын
Thank you so much Christopher for these videos!
@hdanijel
@hdanijel 5 жыл бұрын
again . . .beautiful! love your work! Would you consider making videos about stacks that you mention, with pop push and pointers (code included :P like always) also queues, linked lists and others . . .also algorithms like sorting and . . .you know. I love this playlist. LOVE it!
@Cempa666
@Cempa666 4 жыл бұрын
Loved all videos so far, any ETA on the next couple of videos, can't get enough :)
@armenchik_dzhan
@armenchik_dzhan 3 жыл бұрын
this is amazing thank you for this playlist!
@seanbuckmaster
@seanbuckmaster Жыл бұрын
Thanks for the series. It was great. Please do more.
@harvanharvan
@harvanharvan 6 жыл бұрын
Thank you super much. Great video.
@Hassanlou
@Hassanlou 2 жыл бұрын
@chris, do you have any plans to continue this series? BTW thanks for all your sharing knowledge not only DP but also others like SOLID.
@cypherk
@cypherk 5 жыл бұрын
Absolutely loved your videos, thanks a lot for these. What happened to the next, though? And for that matter, what happened to the book you mentioned you were writing a while ago?
@plamengeorgiev1388
@plamengeorgiev1388 3 жыл бұрын
Excellent DP for cases where you can replace IFs or other conditions, with SOMETHING that does NOTHING.
@matiascasag
@matiascasag 5 жыл бұрын
Thanks for all the videos! Can you make a video on builder pattern?
@kalahari8295
@kalahari8295 Жыл бұрын
Still the best series ever. Continue 😭
@sneha7130
@sneha7130 5 жыл бұрын
Hey! Can you make a video on builder pattern?
@diegocuencaramos8038
@diegocuencaramos8038 2 жыл бұрын
Please more of this, is awesome!!
@nisevi
@nisevi 6 жыл бұрын
Hi there!! Thank you for this awesome collection of videos about design patterns :) !! One thing, it would be to much to ask if you could sort the collection for starting with the latest updated first?, please. That way I don't have to scroll all the way down when I want to keep watching your videos :).
@vaishalijare8488
@vaishalijare8488 6 жыл бұрын
Hi Chrish, Merry Christmas and in advance Happy New Year! Thanks. I learnt a lot from your videos. Could you please add video on ‘Design Pattern Cluster’?
@ShobiPPpro
@ShobiPPpro 6 жыл бұрын
Superb Videos.... Keep Inspiring
@MrAceman82
@MrAceman82 2 жыл бұрын
Both are books are great. However, I have enjoyed the video. It is very refreshing to reminder of useful patterns
@panosgr7228
@panosgr7228 2 жыл бұрын
Please continue this amazing series! Maybe explain the patterns from "Design Patterns: Elements of reusable Object-oriented software"?
@manishjangra4332
@manishjangra4332 6 жыл бұрын
hey chris...thanks for these videos on design patterns..you are really a good explainer. you make everything simple...Can you please make videos on patterns where you practically implement these patterns.?? It will be very good if you make coding examples of these patterns..thanks in advance.. Rock on
@VisualBRON
@VisualBRON 6 жыл бұрын
Are you going to finish the Design Pattern videos?
@angelrodriguez2259
@angelrodriguez2259 5 жыл бұрын
Replacing conditionals with polymorphism? Sounds so cool that I must try!
@oscardiaz9170
@oscardiaz9170 4 жыл бұрын
I understand polimorfism now thanks to your animal example... thank you!
@igormiholic2817
@igormiholic2817 6 жыл бұрын
i really like your code walks. they're great, short and on point. these are just too long, at least for me.
@StevenMartinGuitar
@StevenMartinGuitar 3 жыл бұрын
Plenty more design patterns to cover 😂 loved these videos and want to see more!
@bsuperbrain
@bsuperbrain 6 жыл бұрын
Please make video about the visitor pattern, make comparison builder vs. factory! So many interesting things have remained. :)
@bobbyr8071
@bobbyr8071 6 жыл бұрын
Great videos Chris, please make a vid on Visitor pattern. Thx
@daniellive590
@daniellive590 3 жыл бұрын
7:30: Supplyimplementation within no animal for all methods requried by the interface of animal
@josecarlosramirez486
@josecarlosramirez486 6 жыл бұрын
New video! Yay!
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
🙂🙂
@asheshsen1
@asheshsen1 6 жыл бұрын
Great content and if not the best, one of the best youtube videos on explaining design patterns and explaining the rationale behind it. I was wondering if you could also do videos on Refactoring. Martin Fowler's "Refactoring" book could be one option, when you have free time. Just a suggestion. Feel free to ignore. I don't mean to put any pressure or demand. Great work. Glad I found your channel and appreciate it :)
@gleisonsubzeroKZ
@gleisonsubzeroKZ 3 жыл бұрын
this series has to continue.
@piotrjaga6929
@piotrjaga6929 Жыл бұрын
Thank you!
@user-yd9xy3rb4x
@user-yd9xy3rb4x 2 жыл бұрын
Damn it's soooo easy and extremely genius!!!!!
@sketchupgoo3683
@sketchupgoo3683 6 жыл бұрын
Hola Christopher! Te saludo desde Perú, la verdad no se si sepas español xD asi que traduciré lo que quería decirte... congratulations! I always view your videos before my classes of Computer Science in my university, and believe me. I understand every word you say Keep in that way! you are doing great! My english is not very good, so don't be rude with me with my comment! Happy New Year! and thanks a lot!
@armandormikopo
@armandormikopo 5 жыл бұрын
Hi Christopher! Excellent job with this playlist. Do you have the intention of continuing it?
@yassineelattar5056
@yassineelattar5056 6 жыл бұрын
Hello MasterAre there any other courses about Design Patterns coming up soon?You are doing a great Work by the way
@arunprasad9716
@arunprasad9716 6 жыл бұрын
Hi can you discuss about patterns for winforms in a desktop application.
@elhamnarangifard7569
@elhamnarangifard7569 6 жыл бұрын
great job! I am just wondering why you havent made video on visitor DP yet!!
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
Thanks :) Sorry about the long patterns break. I’ll continue the pattern series as soon as I can :)
@gustavomesel1637
@gustavomesel1637 5 жыл бұрын
First of all, I gotta say your videos are amazing. I think these are the best explanations about design patterns that I have ever encountered! Awesome work. Now, about the Null Object Pattern, I have a question. You mention that one use of this pattern is to avoid having to check for null at every method (using polymorphism to replace conditionals), but I don't think that this will actually prevent the null checking. If you have a method that takes an Animal a (like in your example) and then you do "return a.speak()", even if there is such a thing as a "NoAnimal" subclass, it would still be possible to send null to that method, and you'd still have to do the checking (since, in some languages like c++, using null can actually crash the program). So the NoAnimal doesn't actually prevent you from doing all the null returns.
@khalilsandal8070
@khalilsandal8070 4 жыл бұрын
up
@belugaaa6649
@belugaaa6649 4 жыл бұрын
Hey Christopher okhravi, please finish these series :)
@alexdavies4121
@alexdavies4121 2 жыл бұрын
How about when integrating with other services and you have to check for a null response is a patter suitable for this, or when you check a database for a value and it is not there. I think these scenarios, conditionals are unavoidable.
@leonardoalfonso657
@leonardoalfonso657 6 жыл бұрын
Hi man. It's possible if you can make two videos about Builder and Visitor Pattern? Thanks.
@AnotherFancyUser
@AnotherFancyUser 6 жыл бұрын
Any chance you discuss Repository Pattern with/without Unit Of Work?
@deathkillertech
@deathkillertech Жыл бұрын
Thanks
@younessfathi1739
@younessfathi1739 5 жыл бұрын
thank you
@RS-so7ke
@RS-so7ke 6 жыл бұрын
Hello Christopher, merry christmas. My question is if an interface method is declared to return some object, what will the Nullobject implementing that interface return on that particular method invocation
@khennouchefaycal2123
@khennouchefaycal2123 6 жыл бұрын
I think the default things like if it of type a string then it will return "" (empty string) if int it will return 0 you can call them ground rules ... what do you think Christopher ?
@RS-so7ke
@RS-so7ke 6 жыл бұрын
khennouche faycal makes sense and if it returns some custom object do we again return a NullObject? so what can be a base condition in this case
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
I agree. If there is a sensible default value, we should probably return the sensible default. In many cases there are no sensible defaults however and in that case we should, as you say, return another null object with the same parent type as the thing that we would have returned if we had a value. Thanks to both of you for watching and commenting! :) :)
@wobius
@wobius 6 жыл бұрын
visitor pattern would be great :)
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
It will definitely come but I can unfortunately not make promises in regards to when :) Terribly sorry about the delay but thanks a ton for sticking with the channel! :) I'm glad that you appreciate the videos :) Happy hacking and thanks for commenting :)
@sv3167
@sv3167 3 жыл бұрын
exactly what I was about to write! Need another great explanation of design pattern
@user-de3kt4jm9v
@user-de3kt4jm9v 3 жыл бұрын
Great!
@hagopvittali3465
@hagopvittali3465 6 жыл бұрын
Chris Thank you!, Please make a video about MVC pattern! we need to discuss about it a lot!!
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
So MVC will most probably be a part of this series but unfortunately it might take a while before the video is dropped. Should drop some time during the summer though. Thanks for understanding and thanks a ton for watching the series :) :)
@hagopvittali3465
@hagopvittali3465 6 жыл бұрын
Thank you my friend! we are waiting for your video about MVC, may the force be with u!
@kesavanarayana6257
@kesavanarayana6257 6 жыл бұрын
Hi Chrish, Can you make one video on, How to handle all exception at one place in custom library where we have hundreds of classes and all are independent to each other or may be we have different groups of classes (group is nothing but may be inherited from one abstract class or interface) instead of maintaing inside each method of a concrete type. What are the best practices to handle this kind of scenario.
@FR12321
@FR12321 6 жыл бұрын
You can have a look at AppDomain.UnhandledException for logging purposes, ie. a log file, a messagebox to the user, ... But otherwise, exceptions are used to indicate a failure state and you have to handle them in the calling code if you can do something about it, ie. A ConnectionRetryDecorator could handle the exception of an IConnection and retry a number of times. I don't see how you would have all your exceptions handled in the same place without creating a huge smoke factory that will be painful to debug, ie. how would you handle both a connection exception and an argument exception in the same location?
@mko3294
@mko3294 5 жыл бұрын
thanks man...
@hugforfree
@hugforfree 5 жыл бұрын
How about Chain of Responsability pattern? =)
@magicvortex
@magicvortex 5 жыл бұрын
Will there be next one?
@kamilwitkowski2521
@kamilwitkowski2521 Жыл бұрын
the best !!!
@ofpcwcef
@ofpcwcef 5 жыл бұрын
OMG! Why did you stop :( ?
@sashatyurkina
@sashatyurkina 6 жыл бұрын
Could you please also make video explaining Visitor Pattern?
@jesuscruzhernandez8439
@jesuscruzhernandez8439 Жыл бұрын
#Continue this series please!
@irsham-ali
@irsham-ali 6 жыл бұрын
can one pattern be used "within" or "alongside" another?
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
Absolutely! Both. Great question 🙂 Thanks for watching 🙂
@wittyhumour29
@wittyhumour29 6 жыл бұрын
Hey Chris, as a self taught programmer what should I learn next (Data Structures & Algorithms) or (Design Patterns) ? I know/understand Object Oriented Programming :)
@ChristopherOkhravi
@ChristopherOkhravi 6 жыл бұрын
I would humbly vote data structures and algorithms. More fundamental in my mind. But this playlist should give you an idea of design patterns as well without having to invest too much time :) :) Best if luck!
@wittyhumour29
@wittyhumour29 6 жыл бұрын
Thank you so much 😃 , I will now go for a book on Algorithms and Data Structures & will watch your videos from the Design Pattern Series. Thanks Again !
@mohamedayaou8365
@mohamedayaou8365 3 жыл бұрын
You can find most of these design patterns implemented using PHP in that repo: github.com/domnikl/DesignPatternsPHP
@sticksen
@sticksen 5 жыл бұрын
Isn´t this pattern kind of breaking Interface Segregation? Because you´re using an interface without really wanting to implement things...
@ahmedmahboub2199
@ahmedmahboub2199 3 жыл бұрын
is there any hope that ..this will be completed ?
@auditore63
@auditore63 9 ай бұрын
Please make a video about the builder pattern
@oceanhugstheshore
@oceanhugstheshore 6 жыл бұрын
Please please please make a visitor pattern video!
State Pattern - Design Patterns (ep 17)
1:20:30
Christopher Okhravi
Рет қаралды 147 М.
Iterator Pattern - Design Patterns (ep 16)
1:37:25
Christopher Okhravi
Рет қаралды 92 М.
ДЕНЬ РОЖДЕНИЯ БАБУШКИ #shorts
00:19
Паша Осадчий
Рет қаралды 6 МЛН
New Gadgets! Bycycle 4.0 🚲 #shorts
00:14
BongBee Family
Рет қаралды 12 МЛН
Command Pattern - Design Patterns (ep 7)
39:12
Christopher Okhravi
Рет қаралды 263 М.
Why Use Design Patterns When Python Has Functions?
23:23
ArjanCodes
Рет қаралды 97 М.
Structural Patterns (comparison) - Design Patterns (ep 12)
36:22
Christopher Okhravi
Рет қаралды 92 М.
Factory Method Pattern - Design Patterns (ep 4)
27:21
Christopher Okhravi
Рет қаралды 532 М.
Difference Between Composite and Decorator Pattern - Design Patterns (ep 15)
31:41
The 5 Way Null Object: A Game-Changer For After Effects
13:11
Nijat Ibrahimli
Рет қаралды 17 М.
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
Alex Hyett
Рет қаралды 175 М.