从源码中抽取设计模式对于提高软件可理解性和可维护性、软件设计重用以及软件重构具有重要意义。文章面向Java语言提出了一个从源码中抽取设计模式的方法。具体地,研究了一种特定的设计模式描述方法、定义了源码信息模型及其化简方法,以此为基础提出了设计模式模型和源码模型的匹配方法。特别讨论了在抽取设计模式时与container类相关的问题及其解决方案。最后根据抽取结果从模式及其实例的角度对方法进行了评价,并提出了必要的优化技术。
Identifying design patterns from source code is one of the most promising methods for improving software maintainability,reusing experience and facilitating software refactoring.In this paper,an approach of detecting design patterns from java source code is presented,We have described a method of presenting design pattern and defining a source information model and its extraction mechanism.Through matching pattern model and source information model,an algorithm of detecting pattern instances is illustrated with examples.Especially,we have explained container problem that come across in design pattern detection and resolution of it.Finally,the results of executing the search algorithm are analyzed and optimized as far as the relation between design patterns and design pattern instances are concerned.