从统一建模语言模型中自动识别出相应的设计模式对软件开发具有重要意义,而形式化描述设计模式是自动识别的基础,为此,提出一种基于Petri网的设计模式描述方法。定义从设计模式到Petri网的转换规则,根据规则对观察者模式进行形式化描述,并给出识别设计模式的初步流程。分析结果表明,该方法可以以图形化的方式描述设计模式。在此基础上,能借助Petri网本身的数学理论实现设计模式的自动识别。
It is very meaningful for software development to identify design patterns automatically from Unified Modeling Language(UML) models. Formalization is the base of automatic identification of design patterns, so a method based on Petri net is proposed to describe design patterns. Conversion rules of design patters to Petri net are defined,and observer pattern is formalized by those rules. Preliminary process of automatic identification of design patterns is given. Analysis results show that this method can describe design patterns graphically. On this basis, automatic identification of design patterns can be achieved by means of the mathematical theory of Petri net.