Object Constraint Language

Slides:



Advertisements
Similar presentations
1 Mireille Blay-Fornarino – 2007/2008 EPU département SI, Master STIC Survol de Object Constraint Language & IDM À partir du cours Contracts, Patterns.
Advertisements

Formal Methods of Systems Specification Logical Specification of Hard- and Software Dr. Armin Wolf Fraunhofer Institut für Rechnerarchitektur.
1 ICS-FORTH & Univ. of Crete SeLene November 15, 2002 A View Definition Language for the Semantic Web Maganaraki Aimilia.
Lecture 7 Constraints and Invariants Formal Modeling and Analyzing a Flash File System.
The role of OCL in the Model Driven Architecture Jos Warmer Klasse Objecten
By Karen Richart. The Object Constraint Language (OCL)  Formal specification language that could be used for constraining the model elements that occur.
OCL2 April A presentation of OCL 2 Object Constraint Language Christian Hein, Fraunhofer FOKUS April 2006.
Statecharts Slide: 1. Objectives Learn the concepts for modeling object states Learn Statechart notation to depict object state models Do some modelling…
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Object Constraint Language.
CSCE 431: Interfaces and Contracts Some material from Bruegge, Dutoit.
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
Chapter 9: Object Design: Specifying Interfaces
1 Specifying Object Interfaces. 2 Major tasks in this stage: --are there any missing attributes or operations? --how can we reduce coupling, make interface.
Principles of Object-Oriented Software Development The language Eiffel.
1 Formal Specifications for Complex Systems (236368) Tutorial #5 I/O specifications; Hoare Logic; OCL.
September 2002 R McFadyen1 Domain Model Use Case Model text diagram SSD System operation contracts Design Model Figure 13.3.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Object Constraint Language.
1 Formal Specifications for Complex Systems (236368) Tutorial #7 OCL Object Constraint Language.
Vocabulary word (put this word on the back of the card.) THIS WILL BE THE DEFINITION – FILL IN THE BLANKS ON THE VOCABULARY CARDS PROVIDED.
® Eurostep.ESUKPC v0.1©Copyright Eurostep Limited An Introduction to ISO STEP Part 25 David Price.
Specifications Liskov Chapter 9 SWE 619 Last Updated Fall 2008.
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,
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
Navigation of Class Models So far we have shown how class models can express the structure of an application Here, we’ll show how to express the behavior.
AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,
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.
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.
Uml is made similar by the presence of four common mechanisms that apply consistently throughout the language. After constructing or developing the architecture.
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,
IMPLEMENTING ARRAYLIST – Part 2 COMP 103. RECAP  Abstract Classes – overview, details in 2 nd year  Implementing the ArrayList: size(), get(), set()
UML Model architecture Object Constraint Language Lectures P9-P11 T120B pavasario sem.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
1 OCL The Role of OCL in UML. 2 רשימת הנושאים  מבוא  מרכיבי השפה  דוגמאות  מקורות.
Chapter 9 Applying UML and Patterns -Craig Larman
Introduction to Programming Languages S1.3.1Bina © 1998 Liran & Ofir Introduction to Programming Languages Programming in C.
Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.
IM NTU Software Development Methods, Fall2006 Software Development Methods, Fall 2006 OCL 2006/12/ Object Constraint Language (OCL) Yih-Kuen Tsay.
DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes.
1 Kyung Hee University Constraints Spring Kyung Hee University Graphical Notations  Graphical notations are well suited for displaying structural.
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.
Mr C Johnston ICT Teacher
Domain Model A representation of real-world conceptual classes in a problem domain. The core of object-oriented analysis They are NOT software objects.
Formal Methods in Software Engineering1 Today’s Agenda  Quiz 1 Return  Project Discussion  Quick Review  Finish Introduction to OCL.
University of Florida’s dchecker: Software for ensuring semantic data integrity Nicholas Rejack, MS 1, Christopher P. Barnes 1, Michael Conlon, PhD 2
Interpreting the Object Constraint Presented by: Ed Kausmeyer.
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.
UNIT-IV Designing Classes – Access Layer ‐ Object Storage ‐ Object Interoperability.
The Object Constraint Language
Design by Contract Jim Fawcett CSE784 – Software Studio
Specifications Liskov Chapter 9
The Object Constraint Language
Chapter 9, Object Design: Object Constraint Language
CSCE 606: Interfaces and Contracts
Specifying Object Interfaces
Component-Level Design
Seminar 3 UML Class Diagram.
A Specification Language
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,
MDT OCL 1.3 Mini-deck June 10, 2009.
Object Constraint Language (OCL)
Formal Methods in Software Engineering 1
Software Architecture & Design
Presentation transcript:

Object Constraint Language The OCL is a language of typed expressions. An OCL expression is valid if it is written according to the rules (formal grammar) of OCL. A constraint is a valid OCL expression of type Boolean. A constraint is a restriction on one or more values of (part of) an object-oriented model or system.

self.transaction -> forAll(t:Transaction | t.value > 100) Constraint examples self.transaction -> forAll(t:Transaction | t.value > 100) Account Transaction 1 0..* SuperSaver Account self.balance > 0

Design by contract put (element: T, key: STRING) is -- insert element with given key require count < capacity do .. insertion algorithm ... ensure count <= capacity; item (key) = element; count = old count + 1 end --put

The requirements of OCL 1. The OCL must enable us to express extra, necessary, information on object models. 2. The OCL must be a precise and unambiguous language that can be easily read by developers and customers. 3. The OCL must be a declarative language, its expressions can have no side-effects. 4. OCL must be a typed language so that OCL expressions can be type checked for correctness.

Types in OCL The types in OCL are as follows: Predefined types Basic types - Integer, Real, String and Boolean Collection types - Collection, Set, Bag, Sequence Meta types OclAny, OclExpression, OclType User-defined model types Enumeration and all classes, types and interfaces

The context of an OCL expression Vocabulary Element 0..5 Hint Vocabulary Element self.hintCount <= 5 and self.hintCount >= 0

Real and Integer

Multiplicity constraints Vocabulary VocabElement Hint 1 0..* 1 0..5 Equivalent constraints expressed on the classes VocabElement self.hint -> size >= 0 and self.hint -> size <= 5 VocabElement self.vocabulary -> size = 1 Hint self.vocabElement -> size = 1

String

gender = #male implies title = ‘Mr. ‘ Using Enumerations Customer gender: enum{male, female} name: String title: String dateOfBirth: Date gender = #male implies title = ‘Mr. ‘

Boolean

Simple boolean constraints Customer name: String title: String age: Integer isMale: Boolean title = if isMale then ‘Mr.’ else ‘Ms.’ endif age >= 18 and age < 66 name.size < 100

The implication operation Probably the most counter-intuitive logical operator. A B A implies B T T T T F F F ? T Torches with broken bulbs?

Operations on Collections

Collection hierarchy Collection Set Bag Sequence minus symmetricDifference asSequence asBag asSequence asSet first last at(int) append prepend asBag asSet

Navigating Associations Account Transaction 1 0..* self.transaction returns a set of transactions Book borrower Member self.borrower returns a set of members

Navigating to collections Customer Account Transaction Customer self.account produces a set of Accounts Customer self.account.transaction produces a bag of transactions If we want to use this as a set we have to do the following self.account.transaction -> asSet

The subset constraint Flight Person pilot crew 1..* flightAttendant 0..* Flight self.crew -> includes( self.pilot ) Flight self.crew -> includesAll(self.flightAttendants)

Iteration over collections Account Transaction Account self.transactions -> select( value > 500 ) Account self.transactions -> reject( not(value > 500 )) Account self.transactions -> sum(collect ( value ))

The fact that the Hint class is abstract can be expressed this way. Abstract classes The fact that the Hint class is abstract can be expressed this way. Hint Hint.allInstances -> select(oclType = Hint) -> isEmpty This constraint uses some of the meta facilities which I have mostly glossed over so far.

OCL references Warmer, J. Kleppe, A. The Object Constraint Language: Precise Modeling with UML Addison-Wesley 1999 Object Constraint Language Specification, version 1.1 OMG document ad970808 The OCL parser can be found at http://www.software.ibm.com/ad/ocl The Klasse Objecten web site is http://www.klasse.nl/Engels/ocl.htm