The Rules Engine Design Pattern with C#

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

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

  • @mihaiga
    @mihaiga Год назад +4

    Very concise video, great job. My recommendation would be to encapsulate the ordering inside the rule engine since using an Enum for ordering is not very clean and does not communicate to other developers that there is a dependency between the Enum and the business logic. An improvement for real-world scenarios could be to use the strategy pattern and define a list of ordered rules as a strategy that can be applied. Keep up the good work and I hope to see your channel grow!

  • @codingwithtien
    @codingwithtien Год назад +2

    I had a live coding interview a few years ago and they asked me to solve precisely this topic. Thanks for your video.

    • @spyroskatsios
      @spyroskatsios  Год назад

      You are welcome! Hope you did well in the interview!

  • @ChequeWriter
    @ChequeWriter Год назад

    Good video.

  • @atarconcet
    @atarconcet Год назад

    Good solution, however, I feel that the DiscountRule enum will break the open-closed principle because you will need to modify the enum every time you add a Rule. I would still vote for the order, even if you can assign IDs with gaps, such as ID=100, ID=200. This could give you the freedom to add up to 99 possible rules in between. However, that option isn't perfect either, as it would force you to anticipate what other rules might be added. Nonetheless, it's a good topic and solution. Thanks.

    • @spyroskatsios
      @spyroskatsios  Год назад

      I like your solution! Thanks for your kind words!

  • @manchusandy1
    @manchusandy1 Год назад

    I want to copy the code. Do you have github link for this ?

  • @zefur321
    @zefur321 9 месяцев назад

    can i keep rules in database ?

    • @spyroskatsios
      @spyroskatsios  9 месяцев назад

      Hi! I suppose you could, but in what form are you going to store them?

    • @zefur321
      @zefur321 9 месяцев назад

      @@spyroskatsios now i try to study Drools. but dont know how to install and integrate with eclipse (java).
      so i not sure c# also have rule engine that can keep rules in configuration file, xml or database or not?

  • @georgekalogeropoulos1813
    @georgekalogeropoulos1813 Год назад +3

    Honestly the second version is way more complex 😆

    • @spyroskatsios
      @spyroskatsios  Год назад +3

      You mean the one with the ordering or the one with the rules engine?

    • @MiningForPies
      @MiningForPies Год назад +1

      Yes it is, when you only have a couple of rules.
      When you have 10 or 20 or 50 it’s a lot less so, especially around unit testing.

    • @spyroskatsios
      @spyroskatsios  Год назад +1

      @@MiningForPies Exactly! And that's a trade off with demos around ddd and design patterns. You can't have a complex logic since it's a demo, but they look kind of redundant without it!

  • @JyotiGupta-gu5kk
    @JyotiGupta-gu5kk 3 месяца назад

    Give git for access the code

    • @spyroskatsios
      @spyroskatsios  Месяц назад +1

      Hi! Since i don't have yet a solution for sharing the source code, you can download it from google drive: drive.google.com/file/d/1hZLSkDMGZw5DGfyYlwauR3Ysi9Qqbp1f/view?usp=sharing

    • @JyotiGupta-gu5kk
      @JyotiGupta-gu5kk Месяц назад

      Thanc​@@spyroskatsios

  • @majormartintibor
    @majormartintibor 4 месяца назад

    Good video.