Nice example showing the pattern.
But this „Tax-Problem“ should be solved differently.
Tax should be an abstract property implemented in derived classes with either a constant value for it’s tax or some way to derermine „this’ own tax“. But it should be part of the class and should NOT come from outside.
I know pattern matching is coming from functional programming. But C# can use both paradigms and this is better solved with OOP.
Nevertheless good showing on how the pattern works. 👍
Hi Andreas, you are totally right about how this kind of problem must be solved. But my focus on this code is to show how the pattern works, and my intention was try to used an example more close to the reality. Anyway your comment help me to be more carefull with the examples, i take the challenge, thanks for your time and your comment.
Nice example showing the pattern.
But this „Tax-Problem“ should be solved differently.
Tax should be an abstract property implemented in derived classes with either a constant value for it’s tax or some way to derermine „this’ own tax“. But it should be part of the class and should NOT come from outside.
I know pattern matching is coming from functional programming. But C# can use both paradigms and this is better solved with OOP.
Nevertheless good showing on how the pattern works. 👍
Hi Andreas, you are totally right about how this kind of problem must be solved. But my focus on this code is to show how the pattern works, and my intention was try to used an example more close to the reality. Anyway your comment help me to be more carefull with the examples, i take the challenge, thanks for your time and your comment.
„Must“ is pretty hard. But this problem and the class hierarchy are calling for another approach.
But „hey“: if it works, you are right.