A UML Class Diagram Analyzer Tiago Massoni Rohit

  • Slides: 22
Download presentation
A UML Class Diagram Analyzer Tiago Massoni Rohit Gheyi Paulo Borba Software Productivity Group

A UML Class Diagram Analyzer Tiago Massoni Rohit Gheyi Paulo Borba Software Productivity Group Informatics Center – UFPE October 2004 1

UML and Critical Systems n UML ¡ ¡ n Growing interest Explore concepts Address

UML and Critical Systems n UML ¡ ¡ n Growing interest Explore concepts Address important problems OCL to specify complex constraints Complex structures with class diagrams 2

UML/OCL and Tools n Lack of semantics ¡ ¡ n Some have proposed approaches

UML/OCL and Tools n Lack of semantics ¡ ¡ n Some have proposed approaches Did not stimulate tools for automatic analysis Absence of tool support ¡ ¡ Additional trouble in critical systems Structural modeling errors are hard to detect 3

Subtle Errors when Modeling Critical Systems n Structural errors ¡ ¡ n OCL invariants

Subtle Errors when Modeling Critical Systems n Structural errors ¡ ¡ n OCL invariants may turn a class diagram over-constrained or inconsistent Under-constrained diagrams allow incorrect implementations These problems are desirable to be automatically detected… 4

Contributions n Approach for automatic analysis of UML class diagrams ¡ n A precise

Contributions n Approach for automatic analysis of UML class diagrams ¡ n A precise semantics for class diagrams is given Semantic model: Alloy ¡ ¡ ¡ Object modeling language Analysis tool for concrete feedback Modeled several critical systems 5

Contributions n Semantics by mapping ¡ n Mapping rules from diagrammatic and OCL class

Contributions n Semantics by mapping ¡ n Mapping rules from diagrammatic and OCL class invariants to Alloy We leverage automatic analysis of Alloy to class diagrams ¡ ¡ Automatic generation of snapshots Assertion checking 6

Outline n n Alloy Semantics for UML class diagrams Example Alloy in Critical Systems

Outline n n Alloy Semantics for UML class diagrams Example Alloy in Critical Systems 7

Alloy n n MIT – Software Design Group (Daniel Jackson) Simple language for declarative

Alloy n n MIT – Software Design Group (Daniel Jackson) Simple language for declarative modeling ¡ ¡ n Primarily structural properties Sets, relations and predicate logic Alloy Analyzer 8

UML to Alloy fact Bank. Properties { Account = Ch. Acc all a: Account|lone

UML to Alloy fact Bank. Properties { Account = Ch. Acc all a: Account|lone a. ~accs bk = ~accs } sig Bank { accs: set Account } sig Account{ bk: set Bank } sig Ch. Acc extends Account {} 9

Semantics for Class Diagrams n Initial focus on structural properties ¡ n Avoided constructs

Semantics for Class Diagrams n Initial focus on structural properties ¡ n Avoided constructs with undefined semantics Diagrammatic constructs ¡ ¡ ¡ Classes and interfaces: signatures Binary associations and attributes: relations Generalization: extends 10

Semantics for Class Diagrams n OCL invariants: Alloy facts ¡ Universally quantified on self

Semantics for Class Diagrams n OCL invariants: Alloy facts ¡ Universally quantified on self OCL X. ocl. Is. Type. Of(Y) X. all. Instances X->is. Empty() X->for. All(a|P) X->size() Alloy X in Y X no X all a: X| P #X 11

Analysis Example 12

Analysis Example 12

Analysis Example Snapshot 1 : scope of two Customers and their personal accounts aren’t

Analysis Example Snapshot 1 : scope of two Customers and their personal accounts aren’t related at all (they could be in different banks) 13

Analysis Example Changing the diagram Snapshot 2 (still underconstrained) 14

Analysis Example Changing the diagram Snapshot 2 (still underconstrained) 14

Analysis Example Adding an OCL constraint: context Bank inv customers. Accounts. In. Bank: self.

Analysis Example Adding an OCL constraint: context Bank inv customers. Accounts. In. Bank: self. custs. owned_accs->includes(self. accs) Snapshot 3 (great!) 15

Analysis Example n I’d like to check whether every customer with cards has an

Analysis Example n I’d like to check whether every customer with cards has an account ¡ Within the Customer context: self. card->not. Empty() implies self. owned_accs->not. Empty() n Counterexample: 16

Applications of Alloy in Critical Systems n Radiation Therapy Machine ¡ n n n

Applications of Alloy in Critical Systems n Radiation Therapy Machine ¡ n n n Operation Commutativity Railway System Access Control Air-traffic control 17

Conclusion n n Visual identification of modeling problems Covering many more states than any

Conclusion n n Visual identification of modeling problems Covering many more states than any testing tool Leverage the benefits to UML Class Diagrams Future Work ¡ ¡ ¡ Prototype (translation, analysis) Behavioral Modeling Case studies Denotational semantics for class diagrams Equivalence notion for models 18

Software Productivity Group n www. cin. ufpe. br/spg ¡ ¡ Model refactoring Synchronization model-source

Software Productivity Group n www. cin. ufpe. br/spg ¡ ¡ Model refactoring Synchronization model-source code Semantics Formal Methods 19

Putting Analysis to Work UML class diagram UML object diagrams semantic mapping translation Snapshot

Putting Analysis to Work UML class diagram UML object diagrams semantic mapping translation Snapshot or counterexample Alloy model Alloy Analyzer (SAT Solver) 20

Alloy Analyzer n Two kinds of analysis ¡ ¡ n Simulation Assertion checking Analysis

Alloy Analyzer n Two kinds of analysis ¡ ¡ n Simulation Assertion checking Analysis ¡ Bounded by a scope of objects and relations 21

A UML Class Diagram Analyzer Tiago Massoni Rohit Gheyi Paulo Borba Software Productivity Group

A UML Class Diagram Analyzer Tiago Massoni Rohit Gheyi Paulo Borba Software Productivity Group Informatics Center – UFPE October 2004 22