使用泛型技术消除观察者模式类型依赖 |
Eliminating Type Dependence In Observer Design Patterns By Generic Technology |
投稿时间:2013-01-07 |
中文关键词:设计模式 观察者模式 泛型技术 面向对象 |
英文关键词:design patterns observer generic technology object oriented |
基金项目: |
|
摘要点击次数: 1706 |
全文下载次数: 2544 |
中文摘要: |
观察者模式是一种在用户界面设计中广泛使用的设计模式。在传统的观察者模式实现中,虽然目标和观察者之间的耦合性得到降低,但是目标仍须知道观察者的类型,即所有的观察者必须处于同一继承体系下。在既有代码或第三方库中引入观察者模式,通常的做法是使用多重继承,这种方法不仅不利于对象间的解耦,而且在一些面向对象语言中,多继承功能是受限的。应用泛型技术在强类型语言中设计一种容器,消除模式中的类型依赖,在不改变观察者模式外部接口的前提下,让任意类型都可以充当观察者。在航天可视化遥操作子系统中采用这种方法对系统进行重构,提高 |
英文摘要: |
Observer design pattern is widely used in the user interface design. Although the coupling between subject and observer gets lower in the traditional implementation of observer pattern, the subject still needs to know the type of the observer, i.e., the observers have to be on the same inheritance system. To introduce observer pattern to the third party library, the usual practice is to use multiple inheritance which is not conducive to the decoupling between objects. For some object oriented languages, support to multiple inheritance is limited. This paper proposes a container in the strongly typed language which eliminates the type dependence using the generic technology while not changing the object structure, and let any class have an ability to act as the observer. This method is used to refactor the Space Visual Remote Operation Subsystem,which improves the scalability and reusability of the system. |
赵正旭,张登辉,刘甜.使用泛型技术消除观察者模式类型依赖[J].石家庄铁道大学学报(自然科学版),2013,(3):48-52,69. |
查看全文 下载PDF阅读器 |
|
关闭 |