摘要
基于构件的软件工程(CBSE)已经成为软件开发的主流范型,它包括领域工程和基于构件的开发(CBD)。本文首先以CBSE中的框架为切入点,分析了CBSE的现状,并指出了其中一些不足之处:
现有的一些构件框架仅仅强调给构件提供服务,而忽略了接口层和业务逻辑层的分离;
构件依赖于特定框架的API;
缺乏对单元测试的支持;
缺乏对横切关注点(Cross Cutting Concerns)的模块化支持。
本文主要针对上述不足之处,做了以下一些工作:
以实践为依据,总结了在实施CBD过程中的一些具体问题;
结合一个轻量级构件框架—Spring Framework说明了如何使用Dependency Injection模式解决CBD过程中的构件组装、单元测试等问题;并在具体的项目中加以应用:
将分层的设计思想引入到具体的项目中,解决了CBD过程中常见的接口依赖问题;
分析了软件系统中的横切关注点问题,介绍了实现横切关注点模块化的
方法—AOP,并应用AOP实现了项目中一些横切关注点的模块化。
Component based software engineering (CBSE) now becomes the mainstream methodology at software development. It includes domain engineering and component based development (CBD). In this article, we firstly analyze the present status of CBSE mainly concerning its framework. Some deficiencies are pointed out as follows:
Some present component frameworks focus on the service providing for the components, but the separation of interface layer and business logic layer is ignored;
Components are tightly coupled with the API provided by the framework;
Lacking the support for component unit testing;
Lacking the support for the modularization of crossing cutting concerns. Our work mainly focuses on these deficiencies, and can be summarized as follows:
Some problems encountered at the CBD process have been pointed out, concerning the real world project;
A light weight component framework-Spring framework has been introduced with its underlying dependency injection pattern. The application of the spring framework is discussed in detail, and how to solve the problems concerning component composition and component unit testing as well;
The layer of indirection strategy has been applied in the project, to solve the interface dependency problem we commonly meet at CBD process;
Aspect oriented programming (AOP) has been introduced to solve the modularization of cross cutting concerns, and its application as well.
引文
[BOOP] Clemens Szyperski. Component Software: Beyond Object-Orionted Programming. Addison-Wesley, 1998.
[CJ2EEP] Deepak Alur, Dan Malks, John Crupi. Core J2EE Patterns: Best Prances and Design Strategies(2nd Edition). Prentice Hall PTR, 2003
[Mejb] Ed Roman etc. Mastering Enterprise JavaBeans (2nd Edition). John Wiley & Sons, 2001
[GOF95] Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides. Design Patterns:Elements of Reusable Object-Oriented software. Addison Wesley, 1995
[TCCBSE] Felix Bachman etc. Technical Concepts of Component-Based Software Engineering. Report CMU/SEI-2000-TR-008, Software Engineering Institute, Carnegie Mellon University, 2000.Institute, Carnegie Mellon University, 2000.
[EIP] Gregor Hohpe, Bobby Woolf. Enterprise Integration Patterns. Addison Wesley, 2003
[EjbSpec] http://java.sun.com/products/ejb/
[JavaBeanSpec] http://java.sun.com/products/javabeans/
[DInjection] http://martinfowler.com/articles/injection.html
[AopQCA] http://qca.cn/frameworkdesign/springaop.htm
[Struts] http://struts.apache.org
[SanFrancisco] http://www.cs.vu.nl/-eliens/cmg/html/oo/
[Jdon] http://www.jdon.com/trainning/net_j2ee.htm
[JoshuaTalk] htlp://www.theserverside.com/talks/videos/JoshnaBloch/transcription.html
[UseCase] Ivar Jacobson. Use Cases and Aspects-Working Seamlessly Together. Journal of Object Technology, vol. 2, no. 4, July-August 2003
[CaseStudy] Ivica Crnkovic, Magnus Larsson. A Case Study: Demands on
Component-based Development. Proceedings, 22th International Conference of Software Engineering, Limerick, Ireland. 2000
[BRCBSS] Ivica Cmkovic, Magnus Larsson. Building Reliable Component-Based Software Systems. Artech House, 2002
[OAspectJ] Kiczales etc. An Overview of AspectJ, in European Conference on Object Oriented Programming (ECOOP), Budapest, Hungary, 2001
[ACMT] Magnus Larsson. Applying Configuration Management Techniques to Component-Based Systems. Licentiate Thesis, 2000
[Refactor] Martin Fowler, Kent Beck,John Brant, William Opdyke, Don Roberts. Refactoring: Improving the Design of Existing Code. Addison-Wesley, 1999
[UMLD] Martin Fowler. UML Distilled 3rd Edition. Addison-Wesley, 2003
[DBC] Meyer, Bertrand, Applying Design by Contract. IEEE Computer vol. 2.5, no. 10, Oct 1992
[SoC] Naji Habra. Separation of Concerns in Software Engineering Education, Proceedings for Advanced Separation of Concerns Workshop, 23rd International Conference on Software Engineering, ICSE2001, Toronto, 2001.
[COTS] Neil A. Maiden, Cornelius Ncube. Acquiring COTS Software Selection Requirements. IEEE Software, Vol. 15, No.2, 1998
[AspectJ] Ramnivas Laddad. AspectJ in Action. Manning Publications, 2003
[Rod02] Rod Johnson. Expert One-on-One J2EE Design and Development. Wrox, 2002
[SEPA] Roger S.Pressman. Software Engineering A Practitioner's Approach(Fifth Edition). McGraw-Hill, 2001
[PJSP] Subrahmanyam Allamaraju etc. Professional Java Server Programming J2EE Edition. Wrox Press, 2000
[StrutsF] Sue Spielman. The Struts Framework: Practical Guide for Java Programmers. Morgan Kaufmann, 2002
[JUnit] Vincent Massol. JUnit in Action. Manning Publications, 2004
[CBSF] 刘瑜.张世琨、王立福,杨美清.基于构件的软件框架与角色扩展形态研究.软件学报,Vol.14,No.8,2003
[Uframework] 鲁杰,程家兴.段震.使用框架构建Web应用系统.微机发展,Vol.14,No.5.2004
[SoftArc] 孙昌爱.金茂忠,刘超.软件体系结构研究综述.软件学报,Vol.13,No.7,2002
[JavaPatterns] 阎宏.Java与模式.电子工业出版社,2002
[SoftReuse] 杨芙清.梅宏,李克勤.软件复用与软件构件技术.电子学报.Vol.27,No.2,1999