摘要
中介者模式常被应用于多个对象需要交互的场合。使用传统的面向对象技术的实现方案容易导致代码分散,冗余代码多,可维护性低。使用面向方面技术实现中介者模式的方案,用方面来表达中介者对象,并把构建模式的同事对象所需要的代码也封装到方面中,对象的交互则使用切入点的定义与通知来实现。与传统实现方案相比,基于面向方面技术的实现方案具有代码集中、可读性强、可扩展性强等优点。
Mediator pattern is usually used in the case of interaction of more than one object. The object-oriented implementation of mediator pattern may easily lead to code scattering, heavy code redundancy and lower maintainability. A method based on aspect-oriented programming(AOP) is proposed to implement the mediator pattern, in which the mediator object is represented by an aspect. The colleague object is also encapsulated in the aspect and the object interaction is realized via pointcut and advice. Comparing with the traditional implementation, AOP-based method is more code-concentrating, extensible and readable.
出处
《计算机应用与软件》
CSCD
北大核心
2008年第11期46-47,111,共3页
Computer Applications and Software
基金
国家自然科学基金项目(60673050)
关键词
面向对象
方面
AOP
设计模式
中介者模式
Object-oriented Aspect Aspect-oriented programming Design patterns Mediator pattern