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

2020-02-05  本文已影响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

上一篇 下一篇

猜你喜欢

热点阅读