Master the Power of Composite Pattern in Rich Domain Modeling

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ค. 2024
  • Download the source code for this demo at Patreon: / master-power-of-85848069
    The Composite design pattern is one of the most effective tools for tackling complex problems. As demonstrated in this video, the Composite pattern provides an ideal solution for managing one specific aspect of complex object-oriented models, namely to address the problem of applying multiple calculations or rules as one rule.
    The essence of the Composite pattern, as demonstrated in this video, is to allow treating individual objects and compositions of objects uniformly. This domain modeling concept becomes a powerful tool when tackling complexity in business rules.
    If you take time to walk through the demo from this video, you will witness the process of designing the system in such a way that a single object can do the job of multiple subordinate objects, providing an elegant solution to a serious technical problem.
    You will learn that the final design, when viewed through the lens of SOLID principles, underlines the Single Responsibility Principle and Open Closed Principle, to name a few, in a very elegant and natural way. The end result is an obvious simplification of the once complex domain model.
    Understanding the Composite pattern and applying it effectively in object-oriented design - that is the set of skills every programmer should possess.
    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 TH-cam 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 authorized 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
    #designpatterns #csharp #dotnet
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 17

  • @num1nex337
    @num1nex337 ปีที่แล้ว +22

    Honestly, thank you so much for making those type of videos, as someone who is relatively junior it is hard to find a content that would allow me to level up. Most of the stuffs out there are 50th variation of how to use mediator or create a validation filter, but your videos are golden, they touch real world problems and provide solutions that can be extrapolated to other scenarios aswell.

  • @michaelkoss
    @michaelkoss ปีที่แล้ว +4

    "This is a trick question; you should not like it" 🤣

  • @saifeddinebenromdhane7553
    @saifeddinebenromdhane7553 ปีที่แล้ว +3

    Just wanted to say Thank you, i really do appreciate the kind of content you make.

  • @adiazwise
    @adiazwise ปีที่แล้ว +1

    Great content, Thanks, I'm motivated to follow you courses in Pluralsight on these topics.

  • @ivandrofly
    @ivandrofly 11 หลายเดือนก่อน +1

    Thank you :D

  • @user-jr5wc7xf1j
    @user-jr5wc7xf1j ปีที่แล้ว +1

    tnx for the video

  • @ghevisartor6242
    @ghevisartor6242 ปีที่แล้ว

    Amazing video, this is so helpful as a junior. One question:
    2:05 At line 35,36,37 you register some formatters, did you make a video on those too?
    I see you register them with the interfaces, is it just in case you have to swap the implementation or is there more going on?

    • @zoran-horvat
      @zoran-horvat  ปีที่แล้ว +1

      All those formatters implement the same interface, and so does the composite. That is the primary enabler for the Composite pattern.

  • @SteveNgaiCheeWeng
    @SteveNgaiCheeWeng ปีที่แล้ว +1

    Hi Zoran, what is your thought on using Strategy Pattern for the above requirement?

    • @zoran-horvat
      @zoran-horvat  ปีที่แล้ว

      How would you apply it?

    • @matthewjames1648
      @matthewjames1648 ปีที่แล้ว

      My take is that the main difference will always be: Strategy Pattern will have Type A choose from Types b-n and determine which strategy should be the strategy(ies) to use. Composite Pattern will have Type A compose or aggregate the results from Types b-n in some way.
      So I don't believe Strategy Pattern would be a suitable drop-in replacement here in Zoran's example, unless you really misuse the Strategy Pattern.

  • @hemant-sathe
    @hemant-sathe ปีที่แล้ว

    Excellent video. In business, the discounts or rules for discounts are configured by business people and we don't want any code change or we have a multi tenant application and can't code for every customer. In such scenario the rules get implemented as some policy or a rule set and are stored in text file.
    Please consider showing a small example of how to convert this same discount rules to an external, say json/xml, file and load at the start.

    • @zoran-horvat
      @zoran-horvat  ปีที่แล้ว +2

      I don't plan such a video now. I hope it was clear from the video that the object graph should be created by some object dynamically, rather than statically as I did in the demo.

  • @ghostnguyen
    @ghostnguyen ปีที่แล้ว

    Hi Zoran,
    I think there is a better implementation that using 'true' Composite pattern. Your code still gets machine states which would be source of bug. Do you have repo url so I can create pull request?

    • @zoran-horvat
      @zoran-horvat  ปีที่แล้ว

      There is no repo for this demo. What do you mean by sources of bugs, and what is your suggestion on how to fix that?

    • @ghostnguyen
      @ghostnguyen ปีที่แล้ว

      @@zoran-horvat
      Method GetDiscountAmounts in ChainedDiscounts should and could be improved. It has state, nested loops, two if statements and also middle return statement.
      Suggestion: ChainedDiscounts should be a chain of discounts, not a list of discounts.
      More suggestion. Then you don't need a ChainedDiscounts.