1 OCL The Role of OCL in UML. 2 רשימת הנושאים  מבוא  מרכיבי השפה  דוגמאות  מקורות.

Slides:



Advertisements
Similar presentations
Formal Methods of Systems Specification Logical Specification of Hard- and Software Dr. Armin Wolf Fraunhofer Institut für Rechnerarchitektur.
Advertisements

The role of OCL in the Model Driven Architecture Jos Warmer Klasse Objecten
1 The Object Constraint Language: Expressing Constraints in the UML (Most slides created by Robert B. France, Professor Department of Computer Science,
1 CHAPTER 4 RELATIONAL ALGEBRA AND CALCULUS. 2 Introduction - We discuss here two mathematical formalisms which can be used as the basis for stating and.
OCL2 April A presentation of OCL 2 Object Constraint Language Christian Hein, Fraunhofer FOKUS April 2006.
Feb 2003 R McFadyen1 Contracts (Ch 13) Used to help understand requirements more completely based on assertions; assertions are applicable to any.
Paper Title: On the Precise Meaning of the OCL Constraints Presented by Alla Dove.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Detail Design Extending UML and Object Design. Object Design.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
September 2002 R McFadyen1 Domain Model Use Case Model text diagram SSD System operation contracts Design Model Figure 13.3.
Describing Syntax and Semantics
© The McGraw-Hill Companies, 2006 Chapter 7 Implementing classes.
ACM/JETT Workshop - August 4-5, 2005 UML Modeling using MagicDraw UML for Java Programmers.
SEG4110 – Advanced Software Engineering and Reengineering TOPIC E Object Constraint Language (OCL)
Ranga Rodrigo. Class is central to object oriented programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 1 Introduction to Object-Oriented Programming and.
Understanding Advanced UML Concepts Gerd Wagner
A presentation of OCL 2 Object Constraint Language Fraunhofer FOKUS.
1 COSC 4406 Software Engineering COSC 4406 Software Engineering Haibin Zhu, Ph.D. Dept. of Computer Science and mathematics, Nipissing University, 100.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
111 Writing Protocols in OCL CS 4311 Jos B. Warmer and Anneke G. Kleppe, OCL: The Constraint Language of the UML, JOOP, May Jos B. Warmer and Anneke.
An introduction to specification in VDM-SL At the end of this lecture you should be able to: write a formal specification of a system in VDM-SL; correlate.
SYSC System Analysis and Design1 SYSC 3100 System Analysis and Design Constraints and Contracts The Object Constraint Language.
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Lecture #5 Introduction to C++
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Introduction to Java Java Translation Program Structure
Week III  Recap from Last Week Review Classes Review Domain Model for EU-Bid & EU-Lease Aggregation Example (Reservation) Attribute Properties.
IM NTU Software Development Methods, Fall2006 Software Development Methods, Fall 2006 OCL 2006/12/ Object Constraint Language (OCL) Yih-Kuen Tsay.
CSC 480 Software Engineering Design by Contract. Detail Design Road Map Begin with architectural models  Class model: domain classes  Overall state.
Chapter 3 Part II Describing Syntax and Semantics.
Object Constraint Language
1 Kyung Hee University Constraints Spring Kyung Hee University Graphical Notations  Graphical notations are well suited for displaying structural.
CSC480 Software Engineering Lecture 8-9 September 20, 2002.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
Jairson Vitorino, Cin UFPE May, 2nd 2005
Software Engineering 2 -Prakash Shrestha.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Chapter 5 System Modeling. What is System modeling? System modeling is the process of developing abstract models of a system, with each model presenting.
Chapter 16 UML Class Diagrams.
Interpreting the Object Constraint Presented by: Ed Kausmeyer.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
A UML-Based Pattern Specification Technique Presented by Chin-Yi Tsai IEEE TRANSACTION ON SOFTWARE ENGINEERING, VOL. 30, NO. 3, MARCH 2004 Robert B. France,
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11b: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter.
An association between class Flight and class Person, indicating that a certain group of persons are the passengers on a flight, will have multiplicity.
Jan Pettersen Nytun, UIA, page 1. Jan Pettersen Nytun, UIA, page 2 HISTORY COLLECTION TYPES AND QUERING IN OCL FORMAL LANGUAGE - STATEMENT EXAMPLES CONSTRAINTS.
Modeling with UML – Class Diagrams
UNIT-IV Designing Classes – Access Layer ‐ Object Storage ‐ Object Interoperability.
Analysis Classes Unit 5.
UML-Class Diagrams. UML-Class Diagrams Order placement problem A Company has two types of customers, corporate customers and personal customers. All.
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
Used to help understand requirements more completely
Extending UML.
Chapter 16 UML Class Diagrams.
The Object Constraint Language
Slides by Steve Armstrong LeTourneau University Longview, TX
The Object Constraint Language
Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract, Computer,
Object Constraint Language (OCL)
Formal Methods in Software Engineering 1
DataTypes Nigel Davis
Presentation transcript:

1 OCL The Role of OCL in UML

2 רשימת הנושאים  מבוא  מרכיבי השפה  דוגמאות  מקורות

3 Introduction  OCL notation allows Unified Modeling Language (UML) users more specification precision  Based on logic and discrete mathematics  It is a formal method…much more formal than other software engineering methods  The OCL language is used to express constraints  Constraints specify constant conditions for system being modeled  Evaluated OCL expressions can not have side effects  OCL is a pure declarative language  OCL is a typed language  OCL is UML’s formal constraint language

4 Why OCL?  UML diagram e.g. class, state, or activity not granular enough to provide all relevant aspects of a specification  Need to provide additional constraints about the objects in the model  Such constraints typically described with natural language which can result in uncertainty  Unambiguous constraints need formal languages but they’re often hard to understand by nonmathematical persons  OCL is a formal language for everyone

5 Where to use OCL  To specify invariants on classes and types in the class model  To describe pre- and post conditions on Operations and Methods  To describe Guards  To specify constraints on operations

6 Using OCL  Choose one or more UML diagrams---class, state, or activity  Add OCL expressions stating facts about elements of the diagrams  The expressions are called constraints  Any implementation derived from the model must remain true  Like OOP, OCL expressions operate on objects  However, the result of a complete expression must always be Boolean i.e. true or false

7 OCL Constraint and EA  An OCL constraint is an OCL Boolean expression that evaluates to true or false

8 דוגמא:אילוצים על נישואים

9 נישואים אילוץ 1: EA

10 נישואים אילוץ 2: EA

11 נישואים אילוץ 3: EA

12 נישואים אילוץ 4: EA

13 רשימת הנושאים  מבוא  מרכיבי השפה  דוגמאות  מקורות

14 Referring to UML Model Info  Many properties expressed in UML models can be referred to from OCL:  attributes  operations  navigation are derived from associations  class attributes and operations  states

15 Operations on Real and Integer Types

16 Operations on String Types

17 Operations on Boolean Types

18 The OCL Collection Hierarchy

19 Operations on all Collections

20 Operations on all Collections

21 Specialized Collection Operations

22 Types of OCL expressions Expression TypeSyntaxApplies toSemantics invariantInv:ClassifierThe invariant must be true for all instances of the classifier preconditionPre:Operation Behavioral feature The precondition must be true before the operation executes postconditionPost:Operation Behavioral feature The precondition must be true after the operation executes The keyword result refers to the result of the operation

23 Types of OCL expressions Expression TypeSyntaxApplies toSemantics Query operation body Body:Query operation Defines the body of a query operation Initial valueInit:Attribute Association end Defines the initial value of the attribute or the association end defineDef:ClassifierAdds variables or helper operations to a context classifier letlet:OCL expression Adds local variables to OCL expressions Derived valueDerive:Attribute Association end Defines the derivation rule for the derived attribute or association end

24 רשימת הנושאים  מבוא  מרכיבי השפה  דוגמאות  מקורות

25 דוגמא

26 inv: 1.No account shall be overdrawn by more than 1000$ 2.CeckingAccounts have an overdraft facility. The account shall not be overdrawn to an amount greater than its overdraft limit 3.DepositAccounts shall never be overdrawn 4.The owner must also be an operator

27 inv: 1.No account shall be overdrawn by more than 1000$ Context BankAccount inv balanceValue: self.balance>-1000

28 inv: 1.No account shall be overdrawn by more than 1000$ 2.CeckingAccounts have an overdraft facility. The account shall not be overdrawn to an amount greater than its overdraft limit Context CheckingAccount inv balanceValue: self.balance>=(-overdraftLimit) inv maximumOverdraftLimit: self.overdraftLimit<=1000

29 inv: 3.DepositAccounts shall never be overdrawn Context DepositAccount inv balanceValue: self.balance>=0.0

30 pre: post 1.The amount to be deposited shall be greater than zero 2.After the operation executes, the amount shall have been added to the balance Context BankAccount::deposit(amount:Real) Real pre : amount>0 post: + amount

31 OCL Example: Companies and Employees

32 OCL Example  "No employee may be older than 65 years." context Company inv: self.employee->forAll(age <= 65) Each OCL expression is written in the context of an instance of specific type. In an OCL expression, the reserved word self is used to refer to the contextual instance. For example, if the context is Company, the self refers to an instance of Company.

33 OCL Example  "If a person is employed at a company, it is not unemployed." context Company inv: employee->exists(isUnemployed) = false

34 רשימת הנושאים  מבוא  מרכיבי השפה  דוגמאות  מקורות

35 References  Pressman, Roger S. Software Engineering: A Practitioner’s Approach, 6/e. New York: McGraw-Hill,  Object Constraint Language Specification OMG Available Specification v2.0 May 