=Paper=
{{Paper
|id=Vol-2019/docsymp_9
|storemode=property
|title=UML Class Diagram Composition Using Software Requirements Specifications
|pdfUrl=https://ceur-ws.org/Vol-2019/docsymp_9.pdf
|volume=Vol-2019
|authors=Alexey Tazin
|dblpUrl=https://dblp.org/rec/conf/models/Tazin17
}}
==UML Class Diagram Composition Using Software Requirements Specifications==
UML Class Diagram Composition Using Software Requirements Specifications Alexey Tazin Department of Electrical and Computer Engineering Northeastern University Boston, MA 02115 Email: tazin.a@husky.neu.edu Abstract—Consider a scenario of collaborative software engi- parts among the original diagrams and composition of the neering process in which different software engineering teams optimal diagrams from the selected parts. It is difficult for create different versions of software design that satisfy given software engineers to achieve such reconciliation of diagrams software requirements specifications. Often the software designs are expressed as UML diagrams, e.g., class diagrams. In this or elimination of redundant diagram parts manually since process, the class diagrams developed by different teams have manual process is very time consuming, error prone, and not to be reconciled and only one final diagram should be included scalable for large software projects. In this paper we show the in the final design. The reconciliation process may include the basic steps of the process of automating the selection of the selection of the “best” parts of each proposed diagrams and used best subdiagrams developed by different teams and composing to compose the optimal diagram from the selected parts. It is difficult for software engineers to achieve such a goal manually them into one diagram that satisfies a set of stakeholder needs since manual process is very time consuming, error prone, and and is optimal with respect to a given objective function. One not scalable for large software projects. We are developing an of the issues that we need to address in this research is the approach and algorithms for automating the selection of the best issue of evaluation of the proposed approach. In particular, we subdiagrams developed by different teams and composing them need to insure that the proposed approach is applicable to a into one diagram that is optimal with respect to a given objective function. The final diagram must satisfy software requirements wide variety of types of software requirements related to class specifications that were satisfied by each proposed diagram. diagrams. Towards this aim, we have developed a classifica- The developed approach will be evaluated experimentally by tion of functional software requirements using minimal UML generating random software requirements (expressed in SPARQL metamodel. The current minimal metamodel includes Class, and OWL), generating random class diagrams satisfying these Association, Property, DataType and Generalization classes requirements, generating composed diagrams that satisfy these requirements, and computing two class diagram metrics for each and will be expanded to support commonly used class diagram composed diagram. These metrics are number of classes and elements. Each class of this classification is represented using number of associations. This approach was implemented using SPARQL ASK query [1] template with variables for class Jena, OWL ontologies, ArgoUML, and SPARQL. names, primitive data types and cardinalities. I. I NTRODUCTION II. R ELATED W ORK During large scale software development it is almost im- There are some works [2][3] that describe implementation possible to come up with an optimal software design. A of 3-way merge for UML class diagrams. The main disad- software engineering team may develop a class diagram using vantage of this type of merge is that it requires an original some software requirements specifications and then over time diagram to be used as base of merging two diagrams derived perform refactoring of the diagram. The refactored diagram form it. Chechik et al. [4] describe two merge operators for may or may not be optimal. In this case, the original and the models: algebraic merge and state machine merge. For both refactored diagrams should be reconciled. The reconciliation operators relationships between model elements are created process may include the selection of the best parts of the orig- manually, although the merge is done automatically using a inal and refactored diagrams and composition of the optimal tool. The approach used by Nejati et al. [5] and Odyssey-VCS diagram from the selected parts. Also, different teams may [6] compares UML diagrams based on the syntax only. The create different versions of class diagram that satisfy given method used by Al-Khiaty and Ahmed [7] compares classes software requirements and these versions should be reconciled using their names, attribute names, operation names, relation- in terms of optimization. In another scenario, different teams ship names, and neighbors. All the names are compared based may create diagrams modeling different parts of a system on their semantic similarity using WordNet [8]. Comparison where each diagram has parts that have the same functionality accuracy depends of weight assignment of each similatity and satisfy the same software requirements specifications. It metric. The method used by Nejati et al. [5] compares states is desirable to eliminate such redundant diagram parts. This in hierarchical statechart models using behavioural matching elimination process may include the selection of the best technique. It does not take into consideration the purpose and responsibility of model elements in more general sense. 9) Select the union that has the highest value of the quality Chechik et al. [4] present some common types of overlaps metric. between concepts in different models with informal semantics, This process will be iterative, i.e., the results returned by the semi-formal semantics, and formal semantic properties. This tool will be shown to the teams who will make the decision method does not provide any systematic way to discover over- on the final diagram. laps between elements for class diagram with informal seman- tics or semi-formal semantics. The overlaps are determined A. What is subdiagram? manually. The method used by Costa et al. [9] uses the 3- For the purpose of finding subdiagrams, we use the bidi- way merge. The method uses rules describing the semantics of rected connected multigraphs [17] G = (V, E), where V is the class diagram according to UML metamodel. These rules a set of vertices of the diagram, and E a set of edges of are used to infer indirect relationships between class diagram the diagram. Each edge is a set of two vertices in case of elements. This method supports comparison of only limited undirected, or an ordered pair of vertices in case of directed. number of class diagram types. Some methods [10][11] use A subdiagram G∗ of a given diagram G is defined as a bidi- graph isomorphism [12]. The method used by Rao and Gupta rected connected or disconnected multigraph G∗ = (V ∗ , E ∗ ) [13] compares diagrams as graphs based on their heuristics. where These methods do not recognize the semantics of diagram. ∗ ∗ • V (G ) ⊆ V (G) is the finite set of subdiagram vertices, The approach used by Fahrenberg et al. [14] computes the ∗ ∗ • E (G ) ⊆ E(G) is the finite set of subdiagram edges. conjunction of class diagrams by interpreting them as views of the same model. This approach does not support matching B. How to Find Subdiagrams and Generate Union? of two diagrams with different classes but satisfying the same We execute an exhaustive search to find all possible subsets set of requirements. Semantic approaches used by Maoz et al. of a set A that includes a class, an interface, or a group of [15] enumerate some examples of instances which represent classes or interfaces related with generalization relationship. In the difference between two diagrams. These approaches are the future we are planning to consider groups of classes and incomplete due to small number of examples that can be interfaces related with associations. The time complexity of created. this algorithm is O(2ceil(n/m) ), where n is number of classes III. S OLUTION and interfaces in the diagram and m is average number of classes and interfaces in each Ai . The time complexity of In this section we describe the basic steps of the proposed the union will be O(22ceil(n/m) ). If each Ai on average has process of developing an optimal UML class diagram based on two classes and m = 2 accordingly, the time complexity of multiple diagrams developed by different teams. These steps the union algorithm will be O(2n ). We are going to generate are based on the following assumptions. Two software engi- unions that are connected graphs and do not have classes with neering teams are given the same stakeholder needs (written the same name but different structure. This would reduce time in text) and develop two UML class diagrams based on these complexity of the union algorithm. needs. The diagrams are developed using ArgoUML tool. We will support more UML tools in the future. There is one C. Representing UML Class Diagrams in OWL diagram per package. The stakeholder needs are (manually) The UML class diagram to OWL conversion is based on converted to SPARQL queries. Different names referring to mapping between UML elements and OWL entities offered the same thing are resolved using WordNet, and axioms. by Ontology Definition Metamodel (ODM) specfication [18]. The process begins with inputting such two diagrams and To achieve the mapping we use an existing tool - UML2OWL a SPARQL representation of the stakeholder needs into the by Leinhos 1 . The tool is described in [19]. The tool supports proposed tool. class diagrams in XMI 1.2 format implemented by Poseidon 1) Read two UML diagrams developed using ArgoUML. 4.1. We modified the tool to enable reading class diagrams in 2) Read stakeholder needs expressed as SPARQL queries. XMI 1.2 format implemented by open source ArgoUML. 3) In each of the diagrams, identify all possible subdia- grams. D. Stakeholder Need Query 4) For each pair of subdiagrams compute their union. We express stakeholder need statements related to class 5) For each union, compute the quality metric. diagrams as SPARQL ASK queries. These queries are exe- 6) Map each union to Web Ontology Language (OWL) [16] cuted against ontological representations of class diagrams. A using Ontology Definition Metamodel (ODM) based stakeholder need statement is satisfied by a class diagram if the tool UMLtoOWL that converts ArgoUML class dia- corresponding SPARQL ASK query can be executed against grams to OWL. the class diagram ontology and return true. The example 7) Enrich each union ontology with inferred object and data below shows a need statement expressed using SPARQL query. properties that correspond to derived relationships and This query refers to Cook and Appetizer classes, some object attributes in UML using SPARQL Update axioms. property, and some restriction on this property and class 8) Identify unions that satisfy the given set of stakeholder needs. 1 http://diplom.ooyoo.de/ Appetizer, where the Cook class is subclass of this restriction. _:r2 rdf:type owl:Restriction. The restriction includes minimum cardinality of 0. This need _:r2 owl:onProperty ?p2. statement could be articulated in English as: _:r2 owl:onClass ?c3. _:r2 owl:minQualifiedCardinality “Cook can have appetizer recipes.” ’0’ˆˆxsd:nonNegativeInteger. This query can be mapped to SPARQL as shown below: ?c1 rdfs:subClassOf _:r2 } ASK {:Cook rdf:type owl:Class. WHERE :Appetizer rdf:type owl:Class. { ?c1 rdfs:subClassOf ?r1. :Cook rdfs:subClassOf ?r1. FILTER (NOT EXISTS ?r1 rdf:type Restriction. {?c1 rdf:type owl:Restriction}). ?r1 owl:onProperty ?p1. ?r1 rdf:type owl:Restriction. ?r1 owl:onClass Appetizer. ?r1 owl:onClass ?c2. ?r1 owl:minQualifiedCardinality ?r1 owl:minQualifiedCardinality ’0’ˆˆxsd:nonNegativeInteger } ’0’ˆˆxsd:nonNegativeInteger. ?r1 owl:onProperty ?p1. E. Union Ontology Inferences ?c3 rdfs:subClassOf ?c2. Stakeholder need statements related to class diagrams de- FILTER (?c3 != ?c2 ). scribe to the elements of the class diagrams. A stakeholder ?p1 rdfs:domain ?c1. need statement is satisfied by a diagram if the diagram includes BIND(IRI(CONCAT(STR(?c1), STRAFTER(STR(?c3), ’#’))) AS ?p2) all the elements described by this stakeholder need statement. } Some of these elements are not present in the diagram initially Each newly created restriction will have a different anony- developed by a software engineer but are inferable based on mous name. This is handled internally by Jena [22]. The name other elements not directly described by the stakeholder need of a newly created object property is obtained via concatenat- statement. These inferable elements are derived properties and ing names of the classes corresponding to the variables c1 and derived associations in UML. c3. A stakeholder need statement expressed as a SPARQL ASK 3) Query match RDF graph: OWL semantics can be en- query includes elements of the class diagram ontology in its coded in RDF [23]. RDF models are essentially collections ASK clause. Such a query can be answered using the class triples (predicate, subject, object) that constitute graphs. The diagram ontology and return true if all elements included in the RDF graph shown in Fig. 1 includes a subgraph corresponding query ASK clause are present in the class diagram ontology. to the match pattern of the above SPARQL Update query Some of these elements corresponding to derived properties WHERE clause and the RDF triples asserted during the query and derived associations in UML must be inferred and asserted execution process. Resources c1, c2, c3, p1, p2, r1, r2 of the using axioms. graph correspond to the variables in the query. The query can In our experiments we used an inference engine to infer and find multiple occurrences of subgraphs corresponding to the assert object properties, data properties, and property restric- match pattern and assert multiple groups of triples specified tions; the inferences are based on general OWL axioms in the in the INSERT clause. class diagram ontology and on SPARQL Update queries [20] that assert new axioms into the ontology. The elements inferred and asserted by the query are specified in its INSERT clause. The following example shows an example of axiom inserting query. This axiom infers and asserts an object property and restriction corresponding to derived association in UML. The axiom is represented in ontological terms that correspond to the UML terms. The SPARQL Update query uses Jena reasoner [21]; the inference takes advantage of the general OWL subClassOf transitivity axiom. 1) Axiom description: If there are two classes A and B and a directed association from class A to class B with cardinality 0..∗ at its navigable end, we can infer a directed association with cardinality 0..∗ at its navigable end from class A to any Fig. 1: Axiom SPARQL Update query RDF graph. subclass of class B. 2) SPARQL Update query: The following is query assert 4) Class diagram: Fig. 2 shows a class diagram that a new object property and restriction for the match pattern does not include any derived properties and associations. We specified in the WHERE clause. convert this class diagram to OWL ontology, execute the above axiom query against this ontology, assert a new object property INSERT { ?p2 rdf:type owl:ObjectProperty. and restriction. This new property and restriction correspond ?p2 rdfs:domain ?c1. to the hasAppetizer derived directed association from class ?p2 rdfs:range ?c3. Cook to class Appetizer. This is shown in Fig. 3. Also, Fig. 3 shows the correspondence between classes and associations, a random diagram satisfying this query using previously gen- and axiom query variables. erated diagrams satisfying queries with arbitrary class names. These randomly generated diagrams will be merged into one diagram and become subdiagrams of this diagram. Then, we need to randomly connect these subdiagrams with directed associations. This approach will be used for generating a random set of queries and a pair of class diagrams that will satisfy these queries. V. E XPECTED C ONTRIBUTIONS 1) Most of diagrams are developed based on given stake- holder needs. In case of diagram merging it is important to verify if the merged diagram satisfies the same Fig. 2: Class diagram that does not include derived associa- stakeholder needs. Our method provides means for such tions and properties. verification. 2) Our method allows to generate semantically equivalent merged diagrams, rather than just one merged diagram, thus giving an opportunity for a software developer to select a solution that better satisfies the designers objectives expressed in terms of design quality metrics. The designer can also select the best subdiagrams from any two given diagrams and compose them into one diagram that is optimal with respect to a given objective function. 3) Classification of software requirements specifications using UML class diagram metamodel. 4) Representation of software requirements using a formal language SPARQL. Fig. 3: Class diagram that includes derived association. 5) Automated method of satisfaction of software require- ments by class diagram. 6) Generating random class diagrams for a given set of IV. P LAN FOR E VALUATION AND VALIDATION software requirements. 7) Inference of indirect associations in the class diagram. The developed approach will be verified by generating random software requirements, generating random UML class VI. C URRENT S TATUS diagrams satisfying these requirements, and generating an optimal composed diagram that satisfies these requirements We developed a software implementation of our approach using number of classes and number of associations class with support of limited number of axioms and full support of diagram metrics. The optimal composed diagram can be gen- all elements of a minimal UML metamodel. We developed a erated using these two metrics based the goal of the ultimate classification of functional software requirements using min- application to be designed. If the goal is maintenance, then imal UML metamodel. We outlined a random class diagram we might want to maximize the number of classes metric. generation algorithm. We are planning to finish experimental The number of associations should be minimized in any case validation of our approach with more design quality metrics, in order to reduce complexity of the diagram. In the future, expand minimal UML metamodel to all most frequently used we are also planning to consider more metrics. Each software class diagram elements, and write all the axioms in April 2018. requirement is generated as SPARQL query that asserts OWL facts. For each query template we will generate a set of R EFERENCES more specific templates with specified primitive data type and [1] W3C, “SPARQL 1.1 Query Language.” [Online]. Available: cardinality variables. For cardinality constraints we will use https://www.w3.org/TR/sparql11-query/ 0, 1, a positive integer, and many. Each such template will be [2] M. Alanen and I. Porres, “Difference and union of models,” International used to generate a query with arbitrary class names and a set Conference on the Unified Modeling Language, 2003. [3] Eclipse Project, “Emfcompare.” [Online]. Available: of diagrams satisfying this query. We are going to generate https://www.eclipse.org/emf/compare each random query by randomly selecting a template with [4] M. Chechik, S. Nejati, and M. Sabetzadeh, “A relationship-based specified primitive data type and cardinality variables out of approach to model integration,” Innovations in Systems and Software Engineering, 2012. all the available such templates and randomly specifying class [5] S. Nejati, M. Sabetzadeh, M. Chechik, S. Easterbrook, and P. Zave, names. For each randomly generated query we will generate “Matching and merging of statecharts specifications,” ICSE 2007, 2007. [6] L. Murta, C. Correa, J. G. Prudencio, and C. Werner, “Towards odyssey- vcs 2: Improvements over a uml-based version control system,” In proceedings of the 2008 international workshop on Comparison and versioning of software models (CVSM 08), Leipzig, Germany, 2008. [7] Mojeeb Al-Rhman Al-Khiaty and M. Ahmed, “Uml class diagrams: Similarity aspects and matching,” Lecture Notes on Software Engineer- ing, Vol. 4, No. 1, 2016. [8] T. Pedersen, S. Patwardhan, and J. Michelizzi, “Wordnet::similarity - measuring the relatedness of concepts,” HLT-NAACL, 2004. [9] V. Costa, R. Monteiro, and L. Murta, “Detecting semantic equivalence in uml class diagrams,” SEKE, 2014. [10] R. S. Rao and M. Gupta, “Design pattern detection by greedy algorithm using inexact graph matching,” IJERT, 2013. [11] ——, “Design pattern detection by sub graph isomorphism technique,” International Journal Of Engineering And Computer Science, 2013. [12] G. Chartrand, Introduction to graph theory. New York: Dover Books, 1984. [13] R. S. Rao and M. Gupta, “Design pattern detection by a heuristic graph comparison algorithm,” International Journal of Advanced Research in Computer Science and Software Engineering, 2013. [14] U. Fahrenberg, M. Acher, A. Legay, and A. Wasowski, “Sound merging and differencing for class diagrams,” FASE 2014: Fundamental Ap- proaches to Software Engineering, pp 63-78, 2014. [15] S. Maoz, J. O. Ringert, and B. Rumpe, “A manifesto for semantic model differencing,” In MODELS, pp. 194203. Springer, 2011. [16] W3C, “Web ontology language reference.” [Online]. Available: http://www.w3.org/2004/OWL/ [17] F. Harary, Graph Theory. Addison-Wesley, 1994. [18] OMG, “Ontology definition metamodel.” [Online]. Available: http://www.omg.org/spec/ODM/ [19] S. Leinhos, “Owl ontology extraction and modelling from and with uml class diagrams - a practical approach,” Master’s thesis, University of the Federal Armed Forces Munich, 2006. [20] W3C, “SPARQL 1.1 Update.” [Online]. Available: https://www.w3.org/TR/sparql11-update/ [21] The Apache Software Foundation, “Reasoners and rule engines: Jena inference support.” [Online]. Available: https://jena.apache.org/documentation/inference/ [22] ——, “Apache jena.” [Online]. Available: https://jena.apache.org/ [23] W3C, “Resource description framework (rdf).” [Online]. Available: www.w3.org/RDF/