oop - 访问者设计模式中的循环依赖

标签 oop design-patterns visitor-pattern

关闭。这个问题需要更多focused .它目前不接受答案。












想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post .

4年前关闭。




Improve this question




有没有办法在没有循环依赖的情况下实现访问者设计模式?我的意思是访问者需要一个对象来访问。并且被访问的对象需要访问者接受。最终两者相互依赖。

最佳答案

又找到了!查看 Acyclic Visitor :

引用:

Allow new functions to be added to existing class hierarchies without affecting those hierarchies, and without creating the troublesome dependency cycles that are inherent to the GOF VISITOR Pattern.

关于oop - 访问者设计模式中的循环依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12672543/

相关文章:

c# - 无法创建抽象类或接口(interface)的实例,但它不是抽象类,也不是接口(interface)?

c# - C# ExpressionVisitor 实现的动机是什么?

Java 访问者模式 2

c# - 在 C# 中引用的 Mono.Cecil 中的以下构造是什么?

design-patterns - 访客模式的变体 : Why not move the 2nd dispatch into the visitor's `Visit` method?

java - 如何将用户输入与类中所有对象的实例变量进行比较

c++ - friend 类不适合我?

c++ - 指针困惑

php - 注册表 Php 示例