1 Formal Specifications for Complex Systems (236368) Tutorial #7 OCL Object Constraint Language.

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

1 Mireille Blay-Fornarino – 2007/2008 EPU département SI, Master STIC Survol de Object Constraint Language & IDM À partir du cours Contracts, Patterns.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Dr. Armin Wolf Fraunhofer Institut für Rechnerarchitektur.
Lecture 7 Constraints and Invariants Formal Modeling and Analyzing a Flash File System.
LECTURE 11: Specifying Systems – State Diag’s & OCL
By Karen Richart. The Object Constraint Language (OCL)  Formal specification language that could be used for constraining the model elements that occur.
Extending ASSL: Making UML Metamodell-based Workflows executable © 2010 University of Rostock | Department of Computer Science Jens Brüning, Andreas Wolff.
1 The Object Constraint Language: Expressing Constraints in the UML (Most slides created by Robert B. France, Professor Department of Computer Science,
OCL2 April A presentation of OCL 2 Object Constraint Language Christian Hein, Fraunhofer FOKUS April 2006.
Object Constraint Language in Together Dan Massey Y&L Consulting.
CS 355 – Programming Languages
Feb 2003 R McFadyen1 Contracts (Ch 13) Used to help understand requirements more completely based on assertions; assertions are applicable to any.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Object Constraint Language.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Object Constraint Language.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Object Constraint Language.
CSCE 431: Interfaces and Contracts Some material from Bruegge, Dutoit.
Jan 23, Ron McFadyen1 SSD for a samplePOS Use Case Figure 13.1 Input Events invoke a system operation of the same name same idea as in object-oriented.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
272: Software Engineering Fall 2008 Instructor: Tevfik Bultan Lecture 4: Object Constraint Language.
1 Specifying Object Interfaces. 2 Major tasks in this stage: --are there any missing attributes or operations? --how can we reduce coupling, make interface.
1 Formal Specifications for Complex Systems (236368) Tutorial #5 I/O specifications; Hoare Logic; OCL.
Detail Design Extending UML and Object Design. Object Design.
1 Formal Specifications for Complex Systems (236368) Tutorial #1 Course site : T.A. :Emilia Katz.
CHAPTER 6 Stacks. 2 A stack is a linear collection whose elements are added and removed from one end The last element to be put on the stack is the first.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Object Constraint Language.
1 OCL – The Object Constraint Language in UML OCL website: Textbook: “ The Objection Constraint Language: Precise Modeling with.
SEG4110 – Advanced Software Engineering and Reengineering TOPIC E Object Constraint Language (OCL)
1 The Object Constraint Language Jos Warmer and Anneke Kleppe. OCL: The Constraint Language of the UML, Journal of Object-Oriented Programming, 2(2):10-13,
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.
1COM6030 Systems Analysis and Design © University of Sheffield 2005 COM 6030 Software Analysis and Design Lecture 10 – Classes and operations Dr Richard.
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 4 Objectives  Learn about repetition (looping) control structures.
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.
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
UML-1 3. Capturing Requirements and Use Case Model.
1 OCL The Role of OCL in UML. 2 רשימת הנושאים  מבוא  מרכיבי השפה  דוגמאות  מקורות.
4. The process specification (プロセス仕様) You will learn: (次の内容を学び) The concept of process specification (プロセス 仕様の概念) Notations for process specification (プロセス.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 1 Few comments about midterm I graded very lightly.
IM NTU Software Development Methods, Fall2006 Software Development Methods, Fall 2006 OCL 2006/12/ Object Constraint Language (OCL) Yih-Kuen Tsay.
Institute for Software Integrated Systems Vanderbilt University Object Constraint Language Himanshu Neema Krishnakumar Balasubramanian Jeff Parsons November.
Control Structures II: Repetition.  Learn about repetition (looping) control structures  Explore how to construct and use count-controlled, sentinel-controlled,
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.
Question 1a) What is printed by the following Java program? int s; int r; int i; int [] x = {4, 8, 2, -9, 6}; s = 1; r = 0; i = x.length - 1; while (i.
Emilia Katz, Shahar Dag 1 Formal Specifications for Complex Systems (236368) Tutorial #13 Algebraic Specification and Larch.
Object Constraint Language (OCL) OCL provides a way to develop more precise models using UML What is a constraint in Object Constraint Language? A constraint.
Formal Methods in Software Engineering1 Today’s Agenda  Quiz 2 next class  Presentation Schedule  Quick Review  Build Models Using OCL.
Formal Methods in Software Engineering1 Today’s Agenda  Quiz 1 Return  Project Discussion  Quick Review  Finish Introduction to OCL.
Interpreting the Object Constraint Presented by: Ed Kausmeyer.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 5 Control Structures II: Repetition.
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.
Object-Oriented Analysis and Design
Chapter 8, Object Design: Object Constraint Language
Presentation of a paper on “Model-based Software Testing”
The Object Constraint Language
Chapter 5: Control Structures II
Chapter 5: Control Structures II
Chapter 9, Object Design: Object Constraint Language
The Object Constraint Language
Chapter 9, Object Design: Object Constraint Language
CSCE 606: Interfaces and Contracts
Specifying Object Interfaces
LECTURE 11: Specifying Systems – State Diag’s & OCL
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
Presentation transcript:

1 Formal Specifications for Complex Systems (236368) Tutorial #7 OCL Object Constraint Language

Emilia Katz, Shahar Dag2 OCL Added to UML class diagrams or state-charts Example system specification: LoyaltyProgram system Given: UML class diagram (see additional file)

Emilia Katz, Shahar Dag3 OCL – operations on collections This is the unusual part of notation Collections: Bag, Set, Sequence Bag Set Sequence AsBag AsSet AsSequence Example: Bag{1,1,2,5}.AsSet() = Set{1,2,5}

Emilia Katz, Shahar Dag4 Operations on Collections - examples Set{acc1,acc2,acc3,acc4} → select(balance>100) –Meaning: subset, containing all the accounts with balance > 100 –Generalized syntax: select(a | a.balance>100) select(a : Account | a.balance>100) –The symmetric operation: reject Set{1,2,3,4,5,6} → collect(x | x mod(2)) = Bag{1,0,1,0,1,0} –Evaluates the expression on each of the items in the collection –Generalized syntax: collect(x : Int | x mod(2)) תמיד יופיע תנאי לוגי התוצאה תהיה תת קבוצה של קבוצת המקור תמיד יופיע ביטוי התוצאה לא בהכרח תת קבוצה של קבוצת המקור התוצאה תהיה הפעלה של הביטוי

Emilia Katz, Shahar Dag5 Operations on Collections - examples Set{1,2,3,4,5} → includes(6) = false Set{1,2,3,4,5} → including(6) = Set{1,2,3,4,5,6} Excludes, excluding – symmetric operations Set{{1,2},{2,3},{5,6}} → flatten() = Set{1,2,3,5,6} Set{acc1,acc2,acc3,acc4} → forAll(balance>100) Set{acc1,acc2,acc3,acc4} → exists(a | a.balance>100) התוצאה תהיה ערך בוליאני סינטקס זהה ל-select משטח ברמה אחת בלבד! משמר את סוג ה- collection

Emilia Katz, Shahar Dag6 Loyalty Program System Loyalty program – מועדון לקוחות Program partners – חברות משתתפות Customer – לקוח כלשהו (לאו דווקא חבר מועדון) Membership – הקשר בין חבר המועדון לבין מועדון הלקוחות Customer card – כרטיס מועדון (זהב או כסף) Loyalty account – חשבון בו הנקודות מנוהלות Service – שרות או הטבה שניתנים ע"י החברה (Service level מותנה בסוג החברות במועדון) Transaction – כל אינטרקאציית לקוח-חברה המשנה את מס. הנקודות (earning – מזכה, burning – "שורפת") [בעצם, שימוש ב - Service]

Emilia Katz, Shahar Dag7 OCL => Natural Language (1) 1. context Customer inv title = (if isMale = true then ‘Mr.’ else ‘Ms.’ Endif) Translation: A customer’s title is ‘Mr.’ if he is male, otherwise it is ‘Ms.’ 2. context LoyaltyProgram inv ServiceLevel-> includesAll(Membership->collect(actualLevel)) Translation: The actual service level of a membership must be a service level offered by the LoyaltyProgram

Emilia Katz, Shahar Dag8 OCL => Natural Language (2) 3. context LoyaltyAccount inv points>0 implies transactions->exists(points>0) Translation: The existence of points in a LoyaltyAccount implies at least one transaction that contained points 4. context ProgramPartners inv self.deliveredServices.transactions-> select(oclType()=Burning)->collect(points)->sum() <= self.deliveredServices.transactions-> select(oclType()=Earning)->collect(points)->sum() Translation: The sum of points burned for a ProgramPartner’s offered services must never exceed the number of points earned from its services This is equivalent to: deliveredServices->collect(transactions)

Emilia Katz, Shahar Dag9 Natural Language => OCL(1) 1. Customers must have a minimum age of 18 years context Customer inv age( ) >= The CustomerCard’s “valid from” date must be earlier then the “valid to” date context CustomerCard inv validFrom.isBefore(ValidTo)

Emilia Katz, Shahar Dag10 Natural Language => OCL(2) 3. The printed name on the customer card must be a title followed by the registered name of the customer context CustomerCard inv printedName = Customer.title.concat(Customer.name) 4. The number of service levels is exactly 2 context LoyaltyProgram inv serviceLevel->size() = 2

Emilia Katz11 Pre- and Post-Conditions in OCL 1. For isEmpty() operation of LoyaltyAccount (returns true iff there are no points in the account) context LoyaltyAccount ::isEmpty( ):Boolean pre: -- none post : result = (points=0) 2. The Burn(integer i) operation of LoyaltyAccount context LoyaltyAccount::burn(i: Integer) pre: points >= i and i >= 0 post: points = –i אנחנו מניחים ששום דבר אחר לא משתנה

Pre- and Post-Conditions in OCL We start off with: m() was applied and we got: = = = a0.b.c = Emilia Katz, Shahar Dag12 A m() B c:int b a0 b0 c = 3 b1 c = 5 a0 b1 c = 6 b0 c =

Pre- and Post-Conditions in OCL We start off with: m() was applied and we got: = = = a0.b.c = Emilia Katz, Shahar Dag13 A m() B c:int b a0 b0 c = 3 a0 b0 c =

Emilia Katz14 Built-in OCL Types

Emilia Katz15 Built-in OCL Types OclType –Customer.name() = “Customer” –Customer.attributes() = Set{“isMale”,”title”,”birthDate”,”name”} OclAny Example - e:Earning –e.oclType() = (OclType)Earning –e.oclIsKindOf(Transaction) = true –e.oclIsTypeOf(Transaction) = false

Example – 2013 moed b Emilia Katz, Shahar Dag16