Hi Deiv Mavi,

The answer to your question is: it depends on the use case. For the case you mentioned, it seems to me that Rules Pattern needs a lot of work. I have rewritten the same code into Pattern Matching with decision table. See my GitHub repo. I also have added the same tests as the original ones. You can compare them.

In this case, I prefer decision table, because I can clearly see what are the influencing factors, and I am even able to see which factors are more important than others. Moreover, unit tests can be more focused and more complete based on the decision table, (I haven’t shown in my repo, maybe will do in the future).

There might be use cases for Rules Pattern, if the rules are inter-dependent on each other and hard to separate them into rows in a decision table.

Senior Application Developer. MBA. I write blogs about .NET, Angular, JavaScript/TypeScript, Docker, AWS, DDD, and many others.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store