In this section, we outline the research methodology used to ensure consistency across basic UML models. Initially, we study the UML metamodel, which is provided by the Object Management Group (OMG), Milford, MA, USA. Then, we derive diagram-specific metamodels for the basic UML models independently: use case, class, activity, sequence, and state. In the proposed metamodels, only essential elements relevant to the purpose of this study are represented. Since elements of different metamodels are interrelated, we introduce a comprehensive metamodel that highlights cross-model relations among their elements. Furthermore, we define new consistency rules that correspond to cross-model relations in the comprehensive metamodel.
3.2. Intra-Model Relations
As an initial step, an independent metamodel is constructed for each UML model. The UML has a metamodel that describes its modeling elements and relationships, as defined in the specification document [
2]. We are extending the existing metamodel with additional structural and semantic relations, and retaining only those UML elements involved in the proposed consistency framework. Elements unrelated to consistency verification were omitted to keep the metamodel concise and computationally manageable.
The proposed metamodels are defined at the metamodel level (M2) and are templates for user models defined at the model level (M1). The elements in a user model are treated as instances of corresponding metamodel elements and have the structural and semantic relationships defined at the metamodel level. Thus, consistency rules defined on metamodel elements can be systematically applied to use model elements. This allows for uniform consistency verification of different UML diagrams and ensures the traceability between metamodels and instances of models generated by the user. The proposed metamodels use standard UML multiplicity notations, including exact cardinalities (e.g., 1 or other fixed numbers), 0..1 (zero or one), * (zero or more), and 1..* (one or more), in accordance with the UML specification.
Use Case Diagram. Use cases are a mechanism for capturing the interactions between the system and its users or other systems, using a graphical model and structured text [
25]. Use cases are documented using a high-level use case diagram that includes a set of use cases, actors, and relationships. Use cases represent the system’s functionalities as stated in system requirements, while actors represent hardware, software, or people interacting with the system. Use cases and actors are connected through relationships. In addition to these relationships, use cases themselves may be related to each other through relationships, such as include, extend, and generalization. Each use case has a textual description that captures its essential details. The UML metamodel does not cover textual descriptions of use cases; hence, there is no standard metamodel for them [
26]. We propose a metamodel of use cases that combines graphical elements with textual descriptions, as a preliminary step toward mapping use case model elements to elements in other UML models (to be discussed in the next sections). We build on a textual use case metamodel proposed in [
26].
Figure 6 depicts the proposed metamodel of the use case model, where solid lines denote structural relations while dashed lines denote semantic relations.
As a preliminary step toward constructing a comprehensive metamodel, we retain the UML elements required for consistency management (UseCase, Actor, Association, Include, Extend, ExtensionPoint, and Generalization) and introduce additional elements needed for cross-model mapping.
Each use case is specified with a textual description that identifies its trigger, precondition, postcondition, basic flow, and alternative flow. To reflect this, we introduce a new semantic relation between the UseCase meta class and the TextualDescription meta class. The Include relationship represents mandatory behavior; therefore, it is associated with the basic flow of the base use case. The Extend relationship, on the other hand, reflects a conditional or an optional behavior, and is associated with the alternative flow of the base (extended) use case. Therefore, we introduce a new semantic relation linking the BasicFlow meta class to the Include meta class, in which the basic flow of a base use case may refer to the included use case behavior in one of its steps. Additionally, a new semantic relation is added between the AlternativeFlow meta class and the Extend meta class, since an alternative flow of a base use case (extended) may refer to the behavior of the extending use case.
To facilitate mapping use case diagrams to other UML diagrams, we introduce a new meta class,
ObjectTag, representing domain objects referenced in use case descriptions, and enabling their mapping to elements in other UML models. An
ObjectTag is attached to the textual description to specify the set of domain objects associated with the use case, which correspond to domain entities represented as classes in a class diagram, and shall be represented as lifelines in the corresponding sequence diagram, according to the proposed consistency rules. For instance, the use case “borrow a book” in a library system involves the following objects: book (representing the item to be borrowed), borrower (representing the user who borrows the book), and loan (representing the entity responsible for the borrowing process), as illustrated in
Figure 7. Further analysis may reveal additional objects and add them to the set of object tags.
Class Diagram. The initial stage of modeling is to study the real world, identify essential objects, and represent them as classes [
25]. A class represents a concept or a blueprint for defining a set of similar objects. It consists of attributes and operations. Classes are connected via relationships, which have different types, such as association and generalization. Classes and relationships are the core elements of a class diagram, which captures the system’s structural aspects [
25].
Figure 8 shows the class diagram metamodel. To support consistency management, we retain only the UML class diagram elements required by the proposed framework (
Class,
Property,
Operation,
Parameter,
Association,
MultiplicityElement, and
Generalization) and omit elements that do not participate in cross-model consistency checking. A class consists of attributes (properties) and operations with zero or more parameters. Classes are connected through relationships, which can be classified as either generalization or association. An association has at least two end properties.
Activity Diagram. To represent the system’s dynamic aspects, UML activity diagrams are used. Activity diagrams show the activities in a process, the flow of control from one activity to another, and conditions on the flow [
25]. Hence, they are used to model the workflow of a system, business process, or use case. An activity diagram can be seen as an advanced flowchart, as it can represent all aspects of a flowchart. Still, it has extra expressive power: it can represent parallel activities and handle complex decision-making through guards on control flows.
Figure 9 depicts the activity diagram metamodel. To support consistency management, we retain only the UML activity diagram elements required by the proposed framework (
ActivityNode,
ControlNode,
InitialNode,
FinalNode,
DecisionNode,
MergeNode,
ActivityEdge, and
Guard) and omit elements that do not participate in cross-model consistency checking. An activity metamodel consists mainly of two elements: a node and an activity edge. A node is either an activity node or a control node. A control node can be classified into an initial node, a final node, a decision node, or a merge node. An initial node has one outgoing activity edge, whereas a final node has one or more incoming activity edges. A decision node has one incoming activity edge and two or more outgoing activity edges, while a merge node has two or more incoming activity edges and one outgoing activity edge. An activity edge may have a guard to determine which path is taken when a decision node is reached.
Sequence diagram. UML Sequence diagrams are primarily used to model interactions between actors and objects in a system, as well as interactions among objects [
25]. A sequence diagram depicts the sequence of messages exchanged between system components [
2].
A sequence diagram can be modeled at different levels of abstraction. At a high level, it can be used to illustrate the sequence of exchanged messages between the actors and the system as a black box; this is referred to as a System Sequence Diagram (SSD). At a more detailed level, it can show the internal objects participating in message exchange, which is known as a design sequence diagram.
Figure 10 represents our metamodel of the sequence diagram. To support consistency management, we retain only the UML sequence diagram elements required by the proposed framework (
Interaction,
Lifeline,
Message,
InteractionFragment,
CombinedFragment,
InteractionOperand,
Guard, and
InteractionUse). An interaction consists of a lifeline, a message, and an interaction fragment that captures the execution flow. Each message has a message sort (synchronous or asynchronous), a sender lifeline, and a receiver lifeline. We introduce a new meta class,
Order, to explicitly define message ordering. UML provides ordering using occurrence specifications and general ordering relationships, whereas this sequence metamodel offers a simplified representation, where we explicitly define message ordering required by the proposed consistency rules.
Interaction fragments represent a unit of behavior in a sequence diagram. To group interactions, sequence diagrams use combined fragments (also referred to as frames in graphical notations). Combined fragments contain interaction operands, which are fragments of interactions associated with guards. An “alt” frame denotes alternatives and has two interaction operands, the first one is performed when the value of the guard is determined to be true, and the second one is performed when the value of the guard is determined to be false, as in the case of an if-then-else structure. An “opt” frame, on the other hand, is used to show options and has only one interaction operand, like an if-then structure. When an interaction involves repetition, a “loop” frame can be used, requiring a guard to specify the number of repetitions. A “par” frame is used to represent concurrent interaction, while a “break” frame is used to represent an interruption in the primary interaction. Interaction use allows the reuse of interactions; i.e., an interaction can reference another interaction, which is normally represented on sequence diagrams with a “ref” frame.
State Diagram. A state machine or a state diagram, as called in the UML, is a behavior diagram that illustrates the discrete behavior of a part of a designed system through finite state transitions [
25]. The proper sequence of messages/operations can also be defined using state diagrams. UML defines two kinds of state machine diagrams: behavior state machines, which describe the lifecycle of an object, and protocol state machines, which define the valid sequences of behavioral features to be invoked, such as operations [
2].
Figure 11 depicts the state diagram metamodel. As an initial step toward consistency management, we retain only the UML state diagram elements required by the proposed framework (
State,
Transition,
Trigger,
Guard, and
Event) and omit elements that do not participate in cross-model consistency checking. A state diagram consists of transitions and states. A state represents the invariant conditions or circumstances of an object, belonging to a class, at an instant in time. The invariant may represent a static or dynamic situation. An event is an occurrence at a specific point in time that may trigger a transition. A transition is a change from one state, the source state, to another state, the target state.
3.4. Consistency Rules Definition
Consistency rules to be enforced in the consistency management process are defined. These rules are specified using first-order logic as a knowledge representation method and are subsequently translated into Alloy specifications to enable automated consistency validation, as discussed in the following sections.
Seven consistency rules are defined as part of the development of the LBF-UML framework rather than adopted from an existing catalog of UML consistency constraints. The seven rules were defined to cover both structural and behavioral consistency aspects, capturing the principal traceability relationships through which requirements are propagated across multiple UML views. They were designed to demonstrate how key cross-model traceability relationships can be formally specified and automatically verified within the proposed framework. Rules R1 and R2 ensure that domain entities identified during requirements analysis are consistently represented in structural and interaction models.
Rules R3, R5, and R6 verify that behavioral information expressed in use case descriptions, including triggers and include/extend relationships, is consistently reflected in sequence diagrams. Rule R4 ensures that alternative execution paths specified in use cases are preserved in activity models, while Rule R7 establishes consistency between use case triggers and state-machine behavior. Together, these rules cover both structural consistency (R1–R2) and behavioral consistency (R3–R7) and address relationships whose violations may lead to inconsistent interpretation of system functionality, incomplete requirements traceability, or behavioral mismatches across UML models. The proposed rules are created for the UML diagrams that are addressed in this framework: use case, class, activity, sequence, and state diagrams. These rules are applicable if the elements of the model and the cross-model mappings are available. The framework is extensible and can accommodate additional metamodel elements, UML diagram types, and consistency rules.
Below, we present the newly defined consistency rules for basic UML models. Rules expressed using the word “must” denote mandatory rules, whereas rules specified using the word “should” are recommended to enhance consistency. Let u, u1, and u2 denote use cases, o an object, t a textual description, c a class, s, s1, and s2 sequence diagrams, l a lifeline, tr a trigger, f an alternative flow, a an activity diagram, d a decision node, fr, f1, and f2 frames, st a state diagram, and e an event, then the consistency rules are defined as follows:
Every object o that appears in a textual description t of a use case u must be an instance of a class c in the class diagram. This rule helps to ensure consistency between the requirements captured in use case descriptions and the structural elements represented in class diagrams. A violation occurs when a domain object, described in a use case, does not have a corresponding class representation.
Every object o appearing in a textual description t of a use case u, and hence an instance of a class c in the class diagram (according to Rule 1), must appear in the corresponding sequence diagram s of that use case as a lifeline l. This rule helps maintain consistency between the requirements that are captured in the use case descriptions and the interactions modeled in sequence diagrams. A violation occurs when there is no domain object in a use case description that has a corresponding lifeline in the associated sequence diagram.
For every use case u with a textual description t, there exists a trigger tr of the use case u where this trigger must be the first message in the corresponding sequence diagram s of that use case. The purpose of this rule is to ensure that the interaction behavior represented in the sequence diagram is consistent with the triggering condition specified in the use case description. A violation is observed when the trigger of the use case does not come first in the message flow of the associated sequence diagram.
If a use case u has an alternative flow f in its textual description t, then the corresponding activity diagram a of use case u should include a decision node d. This rule ensures the alternative flows of a use case description are consistent with the corresponding activity diagram. Decision nodes provide the control-flow mechanism required to model alternative behaviors. If an activity diagram associated with a use case containing an alternative flow does not include a decision node, the model may need further review.
If a base use case u1 has an include relationship with another use case u2 (u1 includes u2), then in the corresponding sequence diagram s1 of the use case u1, there should be a frame fr of type ref that refers to the sequence diagram s2 that corresponds to the included use case u2. When an include relationship is defined between use cases, this rule ensures capturing the inclusion in the corresponding sequence diagrams. When the behavior of the included use case is not referenced in the sequence diagram of the base use case, the model needs further review.
If a base use case u1 (extended use case) has an extend relationship with an extending use case u2 (u2 extends u1), then in the corresponding sequence diagram s1 of the base use case u1, there should be a frame f2 whose type is a ref frame, referring to the sequence diagram s2 that corresponds to the extending use case u2, nested inside f1 frame whose type is opt, alt or a break, to denote an optional or an exceptional behavior. When an extended relationship is defined between use cases, this rule ensures that the extending behavior is captured consistently in the corresponding sequence diagrams. When the behavior of the extending use case is not referenced in the sequence diagram of the base use case through an appropriate fragment, the model needs further investigation.
For a use case u with a textual description t containing a trigger tr, if at least one tagged object o belongs to a class c that owns a state diagram st, then the trigger tr must correspond to an event e in at least one of the associated state diagrams. This rule ensures that the trigger of a use case is represented consistently as an event in at least one state diagram associated with the tagged objects. A violation occurs when a use case contains tagged objects whose corresponding classes own state diagrams, but the trigger identified in the use case description is not represented as a corresponding event in any of those state diagrams.