Make Domain Rules Explicit In Any Business Application

Поділитися
Вставка
  • Опубліковано 9 січ 2025

КОМЕНТАРІ • 24

  • @marklord7614
    @marklord7614 11 годин тому +6

    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 6 годин тому

    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 15 годин тому +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 22 години тому +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 11 годин тому +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 19 годин тому +2

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

  • @bphatness3924
    @bphatness3924 20 годин тому +1

    This is why Zoran is the GOAT!

  • @nikolasavic5917
    @nikolasavic5917 17 годин тому +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?

  • @hemant-sathe
    @hemant-sathe 4 години тому

    Great video, cleared the difference between a rule and validation. In a software product, many rules are configurable, some come as data driven, some as logic driven. Also in the settings section, we need to select which rules apply for the running product. (example, settings in VS Code) also configuration using json. Are these covered already or if there is a plan to cover these at least at introductory level of not in depth? TIA.

  • @nickbarton3191
    @nickbarton3191 14 годин тому

    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 9 годин тому +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  9 годин тому +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...

  • @sashbot9707
    @sashbot9707 День тому +1

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

  • @KaineVarley
    @KaineVarley 20 годин тому +1

    Elegant and excellent!

  • @rdoskoch
    @rdoskoch День тому +2

    Excellent 🎉

  • @sandves
    @sandves 11 годин тому

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

    • @zoran-horvat
      @zoran-horvat  11 годин тому +1

      @@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 20 годин тому

    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  20 годин тому

      @@nanny07 That depends on the requirements.

  • @sotsch9280
    @sotsch9280 21 годину тому

    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  21 годину тому +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 20 годин тому +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.