Changhui Xu
1 min readApr 28, 2020

--

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.

--

--

Changhui Xu
Changhui Xu

Written by Changhui Xu

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

Responses (1)