DEV Community

Discussion on: What the hell is pattern matching?

Collapse
 
alexdhaenens profile image
Alex Dhaenens

Well it depends (as usual). I prefer type checking when I only need to get some properties (that are not in the common interface). Or, which was the case when I found this feature, there was too much (legacy) code (that is executed based on the concrete business class) that I could not move to another class or place. In any other case I would indeed prefer the Visitor pattern.
Why do you prefer to use the Visitor pattern?