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?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Cool post, Alex! Learned something new.
I've never encountered this concept before because I tend to always avoid type checking.
In what situations do you use/prefer type checking over avoiding it using e.g. Visitor pattern, pulling up to a common interface, ... ?
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?