Use Null Object Pattern in Your Rich Domain Model

Sdílet
Vložit
  • čas přidán 25. 05. 2023
  • The source code from this demo is available on Patreon: / use-null-object-83554737
    Ever wondered about the impact of the Null Object design pattern on domain modeling? This video offers a deep dive into this fascinating topic, demonstrating how identifying objects that behave like 'zero' can create a more intuitive and friendly model, even in a complex business domain.
    We bring this concept to life through a real-world example, demonstrating the significant influence of 'null objects' in a deep domain model when it comes to implementing essential features. Watch this video to experience this simplifying effect firsthand!
    And not just that, we also reveal situations where you might want to avoid using the Null Object pattern by adding a touch of complexity to your classes, but gaining more from their simple and intuitive public interface. Discover why maintaining a simple public interface could be advantageous over polymorphic Null Object implementation.
    By the end of this journey, you'll be equipped with the know-how to apply these concepts creatively in your domain modeling, ultimately leading to more structured code.
    Thank you so much for watching! Please like, comment & share this video as it helps me a ton!! Don't forget to subscribe to my channel for more amazing videos and make sure to hit the bell icon to never miss any updates.🔥❤️
    ✅🔔 Become a patron ► / zoranhorvat
    ✅🔔 Subscribe ► / @zoran-horvat
    ⭐ Learn more from video courses:
    Beginning Object-oriented Programming with C# ► codinghelmet.com/go/beginning...
    ⭐ Collections and Generics in C# ► codinghelmet.com/go/collectio...
    ⭐ Making Your C# Code More Object-oriented ► codinghelmet.com/go/making-yo...
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    ⭐ CONNECT WITH ME 📱👨
    🌐Become a patron ► / zoranhorvat
    🌐Buy me a Coffee ► ko-fi.com/zoranhorvat
    🗳 Pluralsight Courses ► codinghelmet.com/go/pluralsight
    📸 Udemy Courses ► codinghelmet.com/go/udemy
    📸 Join me on Twitter ► / zoranh75
    🌐 Read my Articles ► codinghelmet.com/articles
    📸 Join me on LinkedIn ► / zoran-horvat
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    👨 About Me 👨
    Hi, I’m Zoran, I have more than 20 years of experience as a software developer, architect, team lead, and more. I have been programming in C# since its inception in the early 2000s. Since 2017 I have started publishing professional video courses at Pluralsight and Udemy and by this point, there are over 100 hours of the highest-quality videos you can watch on those platforms. On my CZcams channel, you can find shorter video forms focused on clarifying practical issues in coding, design, and architecture of .NET applications.❤️
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    ⚡️RIGHT NOTICE:
    The Copyright Laws of the United States recognize a “fair use” of copyrighted content. Section 107 of the U.S. Copyright Act states: “Notwithstanding the provisions of sections 106 and 106A, the fair use of a copyrighted work, including such use by reproduction in copies or phono records or by any other means specified by that section, for purposes such as criticism, comment, news reporting, teaching (including multiple copies for classroom use), scholarship, or research, is not an infringement of copyright." This video and our youtube channel, in general, may contain certain copyrighted works that were not specifically authorised to be used by the copyright holder(s), but which we believe in good faith are protected by federal law and the Fair use doctrine for one or more of the reasons noted above.
    ⭐For copyright or any inquiries, please contact us at zh@codinghelmet.com
    #dotnet #csharp #designpatterns
  • Věda a technologie

Komentáře • 27

  • @codingbloke
    @codingbloke Před rokem +14

    Excellent presentation. Well balanced. None of the "Your doing X wrong!!" hysterics here.

    • @zoran-horvat
      @zoran-horvat  Před rokem +12

      The greatest secret of software design is that every decision is a tradeof.

  • @tarsala1995
    @tarsala1995 Před rokem +9

    I rarely watch videos twice. This one opened my eyes. I think your videos are reminding us how we should look at the code.

    • @zoran-horvat
      @zoran-horvat  Před rokem +1

      Thank you for your comment. I am glad to hear the video was helpful.

  • @Bankoru
    @Bankoru Před rokem +6

    Essentially creating an algebra by adding an Identity element under the Add binary operator.

  • @cnaegle
    @cnaegle Před 9 měsíci +1

    Great presentation from one of my favorite instructors! Making my development team watch it.

  • @driden1987
    @driden1987 Před 11 měsíci

    Haven’t programmed in C# for a couple of years now, still loving the examples. Good job !

  • @robertmrobo8954
    @robertmrobo8954 Před rokem +5

    Thank you for not using the default 'Order, product and Order Items' examples. 😊

  • @majixx
    @majixx Před rokem +2

    Thank you again Zoran. Brilliant video!

  • @7th_CAV_Trooper
    @7th_CAV_Trooper Před 3 měsíci +1

    omg, a list of my favorite books.

  • @t304pk
    @t304pk Před rokem +4

    Thank you for the impressive video, as always.

  • @tplummer217
    @tplummer217 Před 9 měsíci +1

    Another excellent video sir!

  • @10199able
    @10199able Před rokem +8

    "poor man's polymorphism"

    • @zoran-horvat
      @zoran-horvat  Před rokem +2

      Oh yes, you can find it everywhere.

    • @josebarria3233
      @josebarria3233 Před rokem

      That makes you wonder which one is rich man polymorphism

    • @zoran-horvat
      @zoran-horvat  Před rokem +5

      @@josebarria3233 Just polymorphism.

  • @thygrrr
    @thygrrr Před 16 dny

    "There are obviously two kinds of money - Zero and Non-Zero"
    Me: "Wait... You guys have non-zero money?"

  • @5cover
    @5cover Před rokem +3

    IMO there's a flaw in your current implementation, as it is possible create a Money object with Currency.Empty and a non-zero amount.
    So it is possible to handle money without a currency.
    A possible solution is to throw an exception in the constructor if currency equals Currency.Empty.
    Also I would rename Currency.Empty to Currency.None, as there's no such thing as an "empty" currency.

  • @thygrrr
    @thygrrr Před 16 dny

    8:30 "Money has just become abstract"
    ... not just...

  • @m4inline
    @m4inline Před rokem +3

    Ming the Merciless retired as a coder?

  • @malzsmith
    @malzsmith Před rokem +1

    I'm loving your videos! Do you have plans to make content about async programming and synchronization?

    • @zoran-horvat
      @zoran-horvat  Před rokem +1

      I have one video in the queue that talks about asynchronous programming, which I might record in the near future.

    • @malzsmith
      @malzsmith Před rokem +1

      @@zoran-horvat glad to hear it, thank you!

  • @PedroPabloCalvoMorcillo
    @PedroPabloCalvoMorcillo Před rokem +1

    Great ideas and insights. Not a big fan of throwing exceptions in this case, thought.

    • @zoran-horvat
      @zoran-horvat  Před rokem +4

      There is a more complex design where Money separates "strict" addition from that with mixed currencies. However, subtraction can never be with mixed currencies, except for subtracting a zero...
      For a 100% safe and sound solution, we would need to return an Either monad from all strict methods. But with no syntactic support for errors in C#, the implementation and its use would become significantly more complex and less readable.