美文网首页
Android 设计模式入门到精通之二十:访问者模式(Visit

Android 设计模式入门到精通之二十:访问者模式(Visit

作者: 编程家园 | 来源:发表于2020-02-05 10:22 被阅读0次

访问者模式(Visitor Pattern)

1. 概念

Represent an operation to be performed on the elements of an object structure.Visitor lets you define a new operation without changing the classes of the elements on which it operates.

封装一些作用于某种数据结构中的各种元素,它可以在不改变数据结构的前提下定义作用于这些元素的新的操作。

2. 应用场景

访问模式,对象使用时候,使用一个方法把自己传递回去,其他使用者就可以获悉该对象的所有的非private的对象了。

3. 优点

4. 缺点

5. 代码实践:TBD

相关文章

网友评论

      本文标题:Android 设计模式入门到精通之二十:访问者模式(Visit

      本文链接:https://www.haomeiwen.com/subject/rocrxhtx.html