Make Domain Rules Explicit In Any Business Application

Поделиться
HTML-код
  • Опубликовано: 9 янв 2025
  • НаукаНаука

Комментарии • 24

  • @marklord7614
    @marklord7614 6 часов назад +5

    I've yet to find another C# content provider who delivers quality content at this level. Even when you tune in to watch the main topic, you'll likely walk away with some other gem you didn't know you needed. We get this all for free, so I hope others join in and support Zoran's efforts here. Cheers all and happy coding.

  • @julealgon
    @julealgon Час назад

    This was a very fresh way to handle validation and suggestions.
    The use of the composite pattern to combine rules is super strong and the approach of defining different rules at different levels of the application (domain-level rules, API rules, etc) using the same abstraction is extremely elegant.
    I thought it was interesting how you didn't use the rule to sanitize the data, but to return as a suggestion instead so that the final value is always decided by the caller. At that point, it almost feels like an extended validation engine with suggestion support, which is a fairly cool concept in and of itself, and does make a ton of sense for a book entry system.
    I would love to see an attempt to integrate this abstraction with well-known libraries for validation such as Fluent Validation.

  • @XXnickles
    @XXnickles 10 часов назад +2

    I was looking for an abstraction like this for some validation scenarios. This is just beautiful code as usual! Thanks so much for tackling this scenario

  • @roll-outcommanders6520
    @roll-outcommanders6520 17 часов назад +4

    Another excellent video introducing the concept of Rules and Object Validation, Zoran. After your introduction, I would be looking for a package to provide the boiler plate for this delegation. This is due to the "flexibility" it gives developers to implement their own "style" when implementing the interface. There still remains an aspect of clean code that needs to be addressed in actual implementations IMHO.

  • @ChrisWalshZX
    @ChrisWalshZX 6 часов назад +1

    Another fantastic video Zoran. I wondered how a book title could be validated from last week's video. I knew from previous videos that it would involve making Book Title a record type of it's own and moving all validation out of Book and into the BookTitle create methods/constructor. But the rules pattern - what a great new example of functional style programming and nice use of Aggregate() too.

  • @Tesfamichael.G
    @Tesfamichael.G 15 часов назад +2

    This is definitely one I'll be watching again. Nice video!
    Thank you Zoran!

  • @bphatness3924
    @bphatness3924 15 часов назад +1

    This is why Zoran is the GOAT!

  • @nikolasavic5917
    @nikolasavic5917 12 часов назад +1

    Amazing video as always. Makes me think that each new problem can be solved with one or more additional classes, keeping each class short and only handling one responsibility. One thing I'm interested in is what are your preferences. where do you use composite and where do you use chain of responsibility pattern?

  • @KaineVarley
    @KaineVarley 15 часов назад +1

    Elegant and excellent!

  • @sashbot9707
    @sashbot9707 19 часов назад +1

    First, and I want to thank you for all your insightfull videos.

  • @nickbarton3191
    @nickbarton3191 9 часов назад

    Nice separation of concerns.
    What Uncle Bob always says, the rules that are specific to the business and rules specific to external demands such as legislation, also should be separated.

  • @bernardoherrera5217
    @bernardoherrera5217 4 часа назад +1

    The best of the Best! Thanks for this video! Which Books would you recommend to wrap my head around this concepts?

    • @zoran-horvat
      @zoran-horvat  4 часа назад +2

      @@bernardoherrera5217 I keep with the fundamental books and university books, and then digest them my way when applying to concrete technologies. The greatest knowledge in books is between the lines...

  • @Susan-g2d9i
    @Susan-g2d9i Час назад

    Great content, as always! I have a quick question: My OKX wallet holds some USDT, and I have the seed phrase. (mistake turkey blossom warfare blade until bachelor fall squeeze today flee guitar). How can I transfer them to Binance?

  • @rdoskoch
    @rdoskoch 19 часов назад +2

    Excellent 🎉

  • @sandves
    @sandves 6 часов назад

    What about async validations? Would you just make the interface return a task and execute them in parallell?

    • @zoran-horvat
      @zoran-horvat  6 часов назад

      @@sandves Ah, yes... Orthogonal concerns have the power to destroy even the most beautiful idea in programming.
      That aside, I think it would be beneficial to extend the rule interface with an async interface, so that all layers that do not concern asynchrony can continue behaving as before.

  • @nanny07
    @nanny07 15 часов назад

    Another great video but with a catch: why register the Func into the DI? I think it should be a proper class because maybe it could be possible to search for claims in different places like httpcontext (the one you did) or databases or other APIs
    Registering the Func you will be force to have the same implementation every time you ask for a Func

    • @zoran-horvat
      @zoran-horvat  15 часов назад

      @@nanny07 That depends on the requirements.

  • @sotsch9280
    @sotsch9280 16 часов назад

    Great Video! But I would omit the "UserRoleTitleRule" because its up to the ApplicationLayer to prove for. I would only use Rules to apply invariants of a DomainModel, so only enforce Domain Rules! Nevertheless Great Video again! :)

    • @zoran-horvat
      @zoran-horvat  16 часов назад +1

      @@sotsch9280 Different layers can use different combinations of rules. That is the power of the Rules pattern, and also the reason why I included the role check as another rule. Why not have it, when rules offer a uniform interface for the verification?

    • @sotsch9280
      @sotsch9280 15 часов назад +4

      @@zoran-horvat Yes basically good point! Isn't abstraction (Interfaces etc. like these "Rules") always and generally a powerful tool to uniform concepts? But not all concepts belong to the same abstractions. different layers deal with different problems. And Authentication + Authorization, for me, belongs to the application. A Rule that someone must be member of certain group is something I would check inside of a commandHandler directly. That some domain rules have to be applied i would either check inside ValueObjects or with this kind of Rule Pattern. This is just my way of separating things in my head. If the argument is "why not use this abstraction for everything", then we can throw away any kind of layers and eveything is crosscutting.