Null Object Pattern - Design Patterns (ep 18)

Поділитися
Вставка
  • Опубліковано 16 гру 2024

КОМЕНТАРІ • 179

  • @sayantansengupta9939
    @sayantansengupta9939 3 роки тому +13

    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.

  • @renatoinnocenti
    @renatoinnocenti 6 років тому +133

    Continue this series please!

    • @ChristopherOkhravi
      @ChristopherOkhravi  6 років тому +30

      If all goes well I’ll start dropping episodes again within a month :) Thank you for the patience :) :) And your enthusiasm :)

    • @takssir
      @takssir 6 років тому +3

      @@ChristopherOkhravi hi, do you have any new?

    • @samueljames7071
      @samueljames7071 6 років тому +10

      @@ChristopherOkhravi yes please can you cover the MVC pattern!

    • @fadybichara
      @fadybichara 5 років тому +1

      Hey Chris .. this is very helpful .. I Wish you can continue this amazing series

    • @victorbrylew1775
      @victorbrylew1775 5 років тому +17

      Next episode of this series is NoEpisode. Just handle it correctly!

  • @piyushajmani5
    @piyushajmani5 5 років тому +41

    Where'd you go? I miss you so.
    Please continue the series.

  • @professorfontanez
    @professorfontanez 4 роки тому +16

    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 роки тому +3

      The excellent and vivid examples that you’re scattering over the comment sections truly improve the value of this UA-cam channel so let me just pause and say: thank you! Great examples 😊😊

    • @professorfontanez
      @professorfontanez 4 роки тому +3

      @@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 роки тому +1

      @@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 7 років тому +27

    This is awkward, I didn't get you anything for Christmas... and here you got me just what I asked for.
    Thank you!

  • @Brudof
    @Brudof 2 роки тому +4

    Loved these videos. I learn much better in this format vs reading on my own. Hope to see you continue this series one day.

  • @omarabdo6403
    @omarabdo6403 4 роки тому +1

    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!

  • @dennimer
    @dennimer Рік тому +1

    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!

  • @ZaneSelvans
    @ZaneSelvans 4 роки тому +2

    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!

  • @alexhelkar
    @alexhelkar 5 років тому +1

    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.

  • @akshayvenkatesh5372
    @akshayvenkatesh5372 7 років тому +18

    Great stuff! Please please make a video on Visitor pattern.

  • @TheToeFungi
    @TheToeFungi 5 років тому +12

    What might be quite cool is a git repository with an example of an implementation of the design pattern being explained.

    • @cliid4355
      @cliid4355 4 роки тому +6

      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.

  • @vperaltac
    @vperaltac 6 років тому +8

    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 років тому +2

      Hahahha that is awesome. Serious brain washing :) :) Thank you for watching and I’m glad it was useful :)

  • @shraddheshbhandari8740
    @shraddheshbhandari8740 6 років тому +2

    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 :)

  • @grayboywilliams
    @grayboywilliams 4 роки тому

    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 4 роки тому +1

    Please continue Christopher ! This series was amazing !

  • @SbeveAmogus
    @SbeveAmogus 7 років тому +1

    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

  • @kalahari8295
    @kalahari8295 2 роки тому

    Still the best series ever. Continue 😭

  • @BlockDemos
    @BlockDemos Рік тому

    I just finished this series, thank you very much, Christopher.

  • @txxie
    @txxie 6 років тому +1

    I really like your videos about design patterns. Continue this series, please!!!

  • @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.

  • @daniellive590
    @daniellive590 4 роки тому

    7:30: Supplyimplementation within no animal for all methods requried by the interface of animal

  • @krozaine
    @krozaine 5 років тому +1

    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!!

  • @suhastm6696
    @suhastm6696 3 роки тому

    Thanks for the wonderful series. I have learnt a lot from this design pattern series. Thank you Christopher.

  • @amitrk23
    @amitrk23 4 роки тому

    Thanks a ton for all the videos in this series.
    Understood different design patterns.
    Great teaching :)

  • @SrishtiShukla9911
    @SrishtiShukla9911 5 років тому

    Hi @Christopher Okhravi your videos are great.. Kindly continue this series...

  • @kclee8998
    @kclee8998 5 років тому +1

    Thank you very much for this series.

  • @seanbuckmaster
    @seanbuckmaster 2 роки тому

    Thanks for the series. It was great. Please do more.

  • @guyr989
    @guyr989 5 років тому +5

    Will you continue with your videos?
    If it's about the views I can watch them a million times.

  • @plamengeorgiev1388
    @plamengeorgiev1388 3 роки тому

    Excellent DP for cases where you can replace IFs or other conditions,
    with SOMETHING that does NOTHING.

  • @jeronimocarrizo5855
    @jeronimocarrizo5855 5 років тому +1

    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!!!!

  • @AndrewReeman_RemD
    @AndrewReeman_RemD 6 років тому +1

    Your videos are great! Excellent examples :) Thanks for these. A video on the visitor or flux pattern would be awesome!

  • @konzinovmaverick4539
    @konzinovmaverick4539 7 років тому +1

    Great one dude. This made my christmas

  • @MrAceman82
    @MrAceman82 3 роки тому

    Both are books are great. However, I have enjoyed the video. It is very refreshing to reminder of useful patterns

  • @martinleeuwangh
    @martinleeuwangh 7 років тому

    Thanks, Chris, for another great video. Happy birthday for last week, merry Christmas and a happy new year, too!

  • @StevenMartinGuitar
    @StevenMartinGuitar 3 роки тому

    Plenty more design patterns to cover 😂 loved these videos and want to see more!

  • @sneha7130
    @sneha7130 6 років тому +7

    Hey! Can you make a video on builder pattern?

  • @ColorBaII
    @ColorBaII 5 років тому

    I like this video much. Good job. I completely dived into the topic.

  • @diegocuencaramos8038
    @diegocuencaramos8038 2 роки тому

    Please more of this, is awesome!!

  • @reyazahmed9320
    @reyazahmed9320 6 років тому +1

    Hey Christopher, thanks for your awesome work. Please make a video on the visitor pattern.

  • @VisualBRON
    @VisualBRON 6 років тому +5

    Are you going to finish the Design Pattern videos?

  • @TheMinino123
    @TheMinino123 6 років тому +1

    Thank you so much for all this work. Really appreciated.

    • @ChristopherOkhravi
      @ChristopherOkhravi  6 років тому +1

      And thank you for watching :) And for commenting. I’m glad to hear that the content is useful :) Best of luck with your endeavors!

  • @oscardiaz9170
    @oscardiaz9170 4 роки тому

    I understand polimorfism now thanks to your animal example... thank you!

  • @alexdavies4121
    @alexdavies4121 3 роки тому +1

    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.

  • @Cempa666
    @Cempa666 4 роки тому

    Loved all videos so far, any ETA on the next couple of videos, can't get enough :)

  • @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.

  • @panosgr7228
    @panosgr7228 2 роки тому

    Please continue this amazing series! Maybe explain the patterns from "Design Patterns: Elements of reusable Object-oriented software"?

  • @jesuscruzhernandez8439
    @jesuscruzhernandez8439 2 роки тому +1

    #Continue this series please!

  • @matiascasag
    @matiascasag 6 років тому +1

    Thanks for all the videos! Can you make a video on builder pattern?

  • @stanislavspatari2960
    @stanislavspatari2960 6 років тому

    Great stuff, hope you'll make more series on this topic.

  • @gleisonsubzeroKZ
    @gleisonsubzeroKZ 4 роки тому

    this series has to continue.

  • @Денис-ж3ф5р
    @Денис-ж3ф5р 2 роки тому

    Damn it's soooo easy and extremely genius!!!!!

  • @armenchik_dzhan
    @armenchik_dzhan 3 роки тому

    this is amazing thank you for this playlist!

  • @Lahiru_Udana
    @Lahiru_Udana 6 років тому

    Thank you for this great series

  • @igormiholic2817
    @igormiholic2817 7 років тому

    i really like your code walks. they're great, short and on point. these are just too long, at least for me.

  • @hdanijel
    @hdanijel 6 років тому

    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!

  • @belugaaa6649
    @belugaaa6649 4 роки тому

    Hey Christopher okhravi, please finish these series :)

  • @sketchupgoo3683
    @sketchupgoo3683 7 років тому

    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!

  • @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

  • @wobius
    @wobius 7 років тому +6

    visitor pattern would be great :)

    • @ChristopherOkhravi
      @ChristopherOkhravi  7 років тому +1

      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 4 роки тому

      exactly what I was about to write! Need another great explanation of design pattern

  • @snigdhav7068
    @snigdhav7068 6 років тому

    Thank you so much Christopher for these videos!

  • @angelrodriguez2259
    @angelrodriguez2259 5 років тому

    Replacing conditionals with polymorphism? Sounds so cool that I must try!

  • @harvanharvan
    @harvanharvan 7 років тому

    Thank you super much. Great video.

  • @bsuperbrain
    @bsuperbrain 6 років тому

    Please make video about the visitor pattern, make comparison builder vs. factory! So many interesting things have remained. :)

  • @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 :)

  • @kesavanarayana6257
    @kesavanarayana6257 7 років тому

    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 7 років тому

      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?

  • @magicvortex
    @magicvortex 6 років тому +1

    Will there be next one?

  • @hugforfree
    @hugforfree 6 років тому +1

    How about Chain of Responsability pattern? =)

  • @markomilojevic8792
    @markomilojevic8792 7 років тому +11

    Hi Chris. I watched all of your videos and I have anything to say except - marvellous! I've already shared your videos to many guys, and all of them have same opinion.
    I have question. You are (maybe) the best presenter of design patterns, that I've ever seen, and I would like to see more it from you, and my suggestion would be to check patterns from second chapter in this book: martinfowler.com/books/eaa.html
    I guess this could be beyond scope for this topic, but maybe some separate playlist/topic/videos... just, do it! :D

    • @ChristopherOkhravi
      @ChristopherOkhravi  7 років тому +1

      Thank you very much for the very kind words! And excellent suggestion! Much appreciated. I haven't read the book but I'll definitely look in to it. As you say, it probably deserves it's own playlist but either way I'll give the book a look! Thank you very much again :)

  • @vaishalijare8488
    @vaishalijare8488 7 років тому

    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’?

  • @elhamnarangifard7569
    @elhamnarangifard7569 6 років тому +1

    great job! I am just wondering why you havent made video on visitor DP yet!!

    • @ChristopherOkhravi
      @ChristopherOkhravi  6 років тому +1

      Thanks :) Sorry about the long patterns break. I’ll continue the pattern series as soon as I can :)

  • @ShobiPPpro
    @ShobiPPpro 7 років тому

    Superb Videos.... Keep Inspiring

  • @sticksen
    @sticksen 5 років тому +1

    Isn´t this pattern kind of breaking Interface Segregation? Because you´re using an interface without really wanting to implement things...

  • @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 :).

  • @leonardoalfonso657
    @leonardoalfonso657 6 років тому

    Hi man. It's possible if you can make two videos about Builder and Visitor Pattern? Thanks.

  • @cypherk
    @cypherk 6 років тому

    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?

  • @FR12321
    @FR12321 7 років тому +1

    Hey, it's a very interesting solution when the value null actually means "do nothing" but sadly it doesn't remove the need to check that a parameter is not null before using it...

    • @ChristopherOkhravi
      @ChristopherOkhravi  7 років тому

      Thanks a lot for the comment and for watching 🙂 🙂 If you never introduce nulls but rather instantiate a NullObject of the same type as the thing that you want to be null you can get pretty close to never having to check whether parameters are null. Or am I misunderstanding your point?

    • @FR12321
      @FR12321 7 років тому +1

      What I mean is that when a method accepts a nullable it is still possible to pass it a null. So in practice, the code has to check for that in some way. To me, the null value is problematic because it breaks the inheritance tree : null can be a value of any nullable, whereas an Animal cannot be a value of type Cat (if Cat inherits from Animal)

  • @josecarlosramirez486
    @josecarlosramirez486 7 років тому +2

    New video! Yay!

  • @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.

  • @sashatyurkina
    @sashatyurkina 6 років тому

    Could you please also make video explaining Visitor Pattern?

  • @armandormikopo
    @armandormikopo 6 років тому

    Hi Christopher! Excellent job with this playlist. Do you have the intention of continuing it?

  • @B47UH4N99
    @B47UH4N99 7 місяців тому

    It is like "continue" structure in for,while loop. It exists but is passing loop like nothing happened.

  • @arunprasad9716
    @arunprasad9716 6 років тому

    Hi can you discuss about patterns for winforms in a desktop application.

  • @wittyhumour29
    @wittyhumour29 7 років тому

    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  7 років тому +2

      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 7 років тому

      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 !

  • @bobbyr8071
    @bobbyr8071 7 років тому

    Great videos Chris, please make a vid on Visitor pattern. Thx

  • @ahmedmahboub2199
    @ahmedmahboub2199 4 роки тому

    is there any hope that ..this will be completed ?

  • @strandedinthe0737
    @strandedinthe0737 4 роки тому +1

    You awesome please move on, there is many another patterns, for example builder, saga, etc

  • @AnotherFancyUser
    @AnotherFancyUser 6 років тому

    Any chance you discuss Repository Pattern with/without Unit Of Work?

  • @yassineelattar5056
    @yassineelattar5056 6 років тому

    Hello MasterAre there any other courses about Design Patterns coming up soon?You are doing a great Work by the way

  • @neweins8864
    @neweins8864 4 роки тому

    Why this series is stopped? Now how would I learn? :(

  • @piotrjaga6929
    @piotrjaga6929 Рік тому

    Thank you!

  • @ofpcwcef
    @ofpcwcef 5 років тому +3

    OMG! Why did you stop :( ?

  • @hagopvittali3465
    @hagopvittali3465 6 років тому

    Chris Thank you!, Please make a video about MVC pattern! we need to discuss about it a lot!!

    • @ChristopherOkhravi
      @ChristopherOkhravi  6 років тому +1

      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!

  • @auditore63
    @auditore63 Рік тому

    Please make a video about the builder pattern

  • @RS-so7ke
    @RS-so7ke 7 років тому

    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 7 років тому

      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 7 років тому

      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  7 років тому

      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! :) :)

  • @mohamedayaou8365
    @mohamedayaou8365 4 роки тому

    You can find most of these design patterns implemented using PHP in that repo: github.com/domnikl/DesignPatternsPHP

  • @danzaverdk
    @danzaverdk 6 років тому +1

    where is the next one!!

  • @shivankgoel-p4e
    @shivankgoel-p4e 11 місяців тому

    can you explain momento design pattern

  • @kamilwitkowski2521
    @kamilwitkowski2521 Рік тому

    the best !!!