With the expanding of computer application filed, the deepening of applicationlevel and the increasing of computer software scale, improving the quality andefficiency of software is becoming imminent. During the software developing period,the inconsistency between model and code leads to many problems such as systemfuction’s disconformity with user requirements, software maintenance cost’s increaseand software quality’ reduction and so on. A large amount of research is done on theconsistency detection between models and the analysis technology of code (includingthe reverse engineering) is also quite mature. But consistency detection between modeland code lacks relevant research. Therefore, the consistency detection between modeland code in this article has important necessity and certain innovation.The consistency detection research between model and code needs to analyzemodel and code, and then detects the consistency between them by consistencydetection algorithm. It completes the consistency detection between model and code andfinds the inconsistency. This article aims at UML model and the Java source code tocarry out the consistency detection research.Firstly, this paper gives formalized description of UML Class Diagram andSequence Diagram in order to achieve the automatic parsing of the UML model.Secondly, this paper puts forward a concept of Sequence Diagram Call Graph(SD-CG) and completes the pretreatment of UML model information. The pretreatmentincludes two steps:①Completing the transformation from the associated relationshipbetween classes to the associated attributes of class.②Completing the transformationfrom the Sequence Diagram to Sequence Diagram Call Graph.Thirdly, this paper gets the information of Java classes and the method Call Graph(CG) by the lexical analysis and syntax analysis of Java source code. The Call Graph ismade up of class methods as nodes and the call relation between them as edges toanalysis the dynamic behavior in the source code. It is a static description of therelationship between method calls in the compilation phase, which can closer to runningthe actual way which completes dynamic interaction information analysis of the sourcecode.Lastly, the consistency detection algorithm between UML model and Java sourcecode is designed including the static information consistency detection and the interactive information consistency detection. The graph consistency detectionalgorithm is a NP complete problem. In order to improve the efficiency of consistencydetection, this paper constructs the Class Interaction Graph from Call Graph by usingthe part relation lifting operation in algebra, and then detects the consistency betweenthe Java Class Interaction Graph and UML Class Interaction Graph. After the classinteraction consistency detection, the consistency detection between the SequenceDiagram Call Graph and Java Call Graph is finally done.This paper proposes a framework of consistency detection between the UMLmodel and Java code based on the above theoretical research. After analyzing Javasource code and the XMI model file extracted from the ArgoUML modeling tool, thispaper develops a tool prototype based on this framework. The tools realizes thefollowing functions: analyzing and extracting the UML model information, constructingSequence Diagram Call Graph, constructing Java Call Graph, constructing ClassInteraction Graph, the static information consistency detection and the interactiveinformation consistency detection and so on. Using the example of buying book onlinesystem, the tool locates the inconsistency information and completes the consistencydetection between the model and the code, which verifies the feasibility andeffectiveness of the proposed method. |