22-Visitor

      The assumption is that you have a primary class hierarchy that is fixed; perhaps it’s from another vendor and you can’t make changes to that hierarchy. However, you’d like to add new polymorphic methods to that hierarchy, which means that normally you’d have to add something to the base class interface. So the dilemma is that you need to add methods to the base class, but you can’t touch the base class. How do you get around this?

       The design pattern that solves this kind of problem is called a “visitor”......

       以上是教材的提示部分,然后就是一个例子,我没有深入看,感觉没有多少指示作用,找了一个实例 ,感觉不错,但还不是很满意!主要是没有搞明白那个类是primary class hierarchy构成部分!看来这个visitor模式不是很好理解,好在发现了一个实际应用:dom4j 中的Visitor设计模式有应用支持,这个在后期再仔细消化吧!

      

       

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值