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!
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 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?
@@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!
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
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!
I had a live coding interview a few years ago and they asked me to solve precisely this topic. Thanks for your video.
You are welcome! Hope you did well in the interview!
Good video.
Thanks a lot!
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.
I like your solution! Thanks for your kind words!
I want to copy the code. Do you have github link for this ?
I uploaded it: github.com/spyroskatsios/RUclips-RulesEngineDemo
thanks @@spyroskatsios
can i keep rules in database ?
Hi! I suppose you could, but in what form are you going to store them?
@@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?
Honestly the second version is way more complex 😆
You mean the one with the ordering or the one with the rules engine?
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.
@@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!
Give git for access the code
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
Thanc@@spyroskatsios
Good video.
Thank you! 😊