摘 要: 在模型驱动开发过程中,为了减轻开发人员的负担,通常采用自动工具生成代码框架。本文提出了一种基于活动图与顺序图自动生成代码框架的方法,并且基于该方法开发了原型工具。首先,给出了活动图和顺序图的形式化表达;其次,基于活动图和顺序图模型提出了三个实现自动代码生成的算法,该算法是通过活动图来描述对象内部的活动次序,并且利用顺序图体现对象之间的交互;最后,给出了一个原型工具,实现了模型到代码框架的自动转换。该工作可以确保转换的正确性,并且提高软件开发效率。 |
关键词: 模型驱动开发;自动代码生成;形式化方法 |
中图分类号: TP311.5
文献标识码: A
|
基金项目: 国家自然基金(61772004);国家自然基金(61361136002);福建省自然基金(2018J01777);福建省自然基金(2014J01221);成都信息工程大学引进人才科研启动项目(KYTZ202009). |
|
Automatic Code Generation based on Activity and Sequence Diagrams |
WEN Hao1,2, JIANG Jianmin3, ZHANG Shi1, HONG Zhong1
|
( 1.College of Computer and Cyber Security, Fujian Normal University, Fuzhou 350117, China; 2.Chengdu Institute of Computer Applications, Chinese Academy of Sciences, Chengdu 610041, China ; 3.College of Software Engineering, Chengdu University of Information Technology, Chengdu 610225, China )
caswh96@foxmail.com; jjm@cuit.edu.cn; shi@fjnu.edu.cn; fjfzhz@fjnu.edu.cn
|
Abstract: In the process of model-driven development, automatic tools are usually used to generate code frameworks in order to reduce the burden on developers. This paper proposes a method to automatically generate code framework based on activity diagram and sequence diagram, and a prototype tool is developed based on this method. First, this paper gives a formal expression of activity diagrams and sequence diagrams; secondly, three algorithms for realizing automatic code generation are proposed based on the activity diagram and sequence diagram. The algorithm uses activity diagrams to describe the internal activity sequence of the object and uses the sequence diagram to reflect the interaction between the objects; finally, a prototype tool is given to realize the automatic conversion from the model to the code framework. This work can ensure the correctness of the conversion and improve the efficiency of software development. |
Keywords: model-driven development; automatic code generation; formal methods |