面向方面的编程是解决传统编程技术中横切问题的有效途径之一。为了将传统方法开发的系统转换成面向方面的系统,实现关注分离,提出了一种从遗产系统中发现横切关注点的方法。该方法将聚类分析与程序静态分析方法相结合,基于方法间的直接调用关系,识别面向对象遗产系统中的横切关注点,根据方法调用相似性自动形成候选Aspect集。本方法不受相似行为需要有相同的命名规则的限制,能够避免因横切关注点分离的粒度太细而导致的系统复杂度增加。为Aspect重构提供有用的帮助。
Crosscutting concern is the inherent limitation for traditional programming, and Aspect-Oriented Programming (AOP) is one of the most effective ways to solve this problem. A novel method to discover crosscutting concerns from source-code for transformation from legacy system to Aspect oriented system was proposed. Both the clustering analysis technology and static source-code analysis were used in this method to identify crosscutting concerns from object-oriented legacy system. Direct method invocation relationship was used as the characteristics of scattering code. Candidate Aspects set was generated automatically after clustering. The proposed method was not be limited to the same naming rules for similar behavior and the granularity of candidate aspect, which was much larger leading to the complexity of the system, were also avoided. The method was proved to be effective in the following Aspect reconfiguration and program understanding progresses.