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 Жыл бұрын
I had a live coding interview a few years ago and they asked me to solve precisely this topic. Thanks for your video.
@spyroskatsios Жыл бұрын
You are welcome! Hope you did well in the interview!
@zefur3219 ай бұрын
can i keep rules in database ?
@spyroskatsios9 ай бұрын
Hi! I suppose you could, but in what form are you going to store them?
@zefur3219 ай бұрын
@@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?
@manchusandy1 Жыл бұрын
I want to copy the code. Do you have github link for this ?
@spyroskatsios Жыл бұрын
I uploaded it: github.com/spyroskatsios/KZbin-RulesEngineDemo
@pidjomabeljunior848811 ай бұрын
thanks @@spyroskatsios
@ChequeWriter Жыл бұрын
Good video.
@spyroskatsios Жыл бұрын
Thanks a lot!
@atarconcet11 ай бұрын
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.
@spyroskatsios11 ай бұрын
I like your solution! Thanks for your kind words!
@JyotiGupta-gu5kk2 ай бұрын
Give git for access the code
@spyroskatsios28 күн бұрын
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-gu5kk28 күн бұрын
Thanc@@spyroskatsios
@georgekalogeropoulos1813 Жыл бұрын
Honestly the second version is way more complex 😆
@spyroskatsios Жыл бұрын
You mean the one with the ordering or the one with the rules engine?
@MiningForPies Жыл бұрын
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 Жыл бұрын
@@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!