When should you really use the visitor pattern
问题 Ok before marking this as a duplicate let me clarify myself. I'm reading about the visitor pattern and its applicable uses. I've stumbled upon this post: When should I use the Visitor Design Pattern? and the user who wrote the first answer says as follow : Now we want to add a new operation to the hierarchy, namely we want each animal to make its sound. As far as the hierarchy is this simple, you can do it with straight polymorphism: ... But proceeding in this way, each time you want to add