作者投稿和查稿 主编审稿 专家审稿 编委审稿 远程编辑

计算机工程 ›› 2008, Vol. 34 ›› Issue (10): 73-74. doi: 10.3969/j.issn.1000-3428.2008.10.026

• 软件技术与数据库 • 上一篇    下一篇

基于AOP技术的Composite模式的改进

李光俊1,华庆一1,2,吴海松1   

  1. (1. 西北大学信息科学与技术学院,西安 710127;2. 中科院计算机科学国家重点实验室,北京 100080)
  • 收稿日期:1900-01-01 修回日期:1900-01-01 出版日期:2008-05-20 发布日期:2008-05-20

Improvement of Composite Pattern Based on AOP

LI Guang-jun1, HUA Qing-yi1,2, WU Hai-song1   

  1. (1. College of Information Science and Technology, Northwest University, Xi’an 710127; 2. State Key Laboratory of Computer Science, Chinese Academy of Sciences, Beijing 100080)
  • Received:1900-01-01 Revised:1900-01-01 Online:2008-05-20 Published:2008-05-20

摘要: Composite模式是解决部分与整体关系时常用的设计模式,但基于面向对象设计(OOP)所实现的Composite模式中存在的问题很难利用OOP解决。该文应用面向方面编程(AOP)改变类的行为,利用AspectJ实现Composite模式,通过与以OOP技术实现的Composite模式比较,得出应用AOP方法能够较好地实现责任分离,具有较高的可扩展性,模块结构更清晰。

关键词: 面向方面编程技术, 设计模式, Composite模式

Abstract: Composite pattern is a common design pattern to solve the relationship between part and whole. But it’s not easy to solve the problems in Composite pattern with OOP, such as responsibility tangling, intertwining code, bad reusability. This paper presents the implementation of Composite pattern with AspectJ by changing classes’ behaviors with AOP technology. Compared with Composite pattern with OOP, it proves that the pattern with AOP and AspectJ has better model responsibility cohesion and extensibility.

Key words: AOP technology, design pattern, Composite pattern

中图分类号: