在软件维护任务中,通过阅读用况能有效地帮助维护人员理解软件系统,然而在现实中用况文档往往是过时或残缺不全的.如何通过代码分析还原用况是一大难题.针对上述问题提出了一种针对面向对象程序源代码通过静态代码分析逆向恢复用况的方法.该方法在高层通过分析系统逻辑层高层门面类的对象行为协议来获取用况的高层划分,在底层通过分析OO-BRCG(object-oriented branch-reserving call graph)来得到用况的底层划分,然后结合两方面恢复出最终用况.最后通过实验验证了该方法的有效性,恢复用况时该方法能获得极高的用况覆盖度及可观的准确度.
In the process of software maintenance, the maintainer can obtain helpful information via reading the use case documents. The problem in real software maintenance is that the maintainer can only obtain out-of-date or incomplete information of the use case. To solve this problem, a novel approach is proposed to identify the use case from object-oriented source code in the function logic level of the software system. The analysis of the behavior protocol of the high level decade classes, which interact with user interface in an object-oriented system, is involved to help discovering the high level system running scenarios which are high level parts of the discovered use cases. Then the conventional branch-reserving call graph is extended to an object-oriented compatible version called object-oriented branch-reserving call graph (OO-BRCG). After appropriate pruning process applied on the OO-BRCG, each running path leftover in the pruned OO-BRCG is regarded as a low level part of the discovered use cases. Combining the high level and low level use parts can get the complete use cases. An experiment for this method on an object-oriented system in real world is performed. The results from the experiment show that this approach can gain a very high recall with acceptable loss on the precision. The experiment has confirmed the overall effectiveness of this approach.