Command Pattern vs. Visitor Pattern
问题 Is it generally acceptable to allow a Visitor to modify state of the Receiver, or should that be a Command pattern instead? 回答1: The purpose of the visitor pattern is to allow new operations to be added to a class heirarchy without modification to that heirarchy. I've never seen anyone suggesting that only read-only operations are acceptable. The only limitation is that the added operations should only use the public interface of the class heirarchy. 回答2: I don't think you can make a blanket