我正在读implementing_the_visitor_pattern_without_recursion从Python的食谱,第三版 The implementation with additional Visit Class修复缺陷the one without it,因为它要求。 “这个配方的一个潜在危险是关于产生节点和非节点值的区别 。在实现中,所有节点 自动遍历。这意味着您不能使用 节
我有一个不同的Line类的继承树,从抽象Line-classes开始。我希望能够将每一行与每一行相交,有时候,我也不知道任何运行时类型,例如,我打电话Line.Intersect(Line)(所以我需要双重调度)。这将总是调用被覆盖的最为抽象的过载 - 方法,例如, Circle.Intersect(Line)而不是Circle.Intersect(actualType)。下面是一些示例代码: c
目前我正在使用Visitor Pattern的项目。虽然这种模式的工作,我发现自己写这样的评语: * @param VisitorInterface $visitor The visitor to visit. Visitor模式包括以下接口: VisitorInterface {
public function visit($object);
}
VisitableInterfa