1 ocl the role of ocl in uml. 2 רשימת הנושאים מבוא מרכיבי השפה ...
TRANSCRIPT
![Page 1: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/1.jpg)
1
OCL
The Role of OCL in UML
![Page 2: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/2.jpg)
2
רשימת הנושאים מבואמרכיבי השפהדוגמאותמקורות
![Page 3: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/3.jpg)
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
![Page 4: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/4.jpg)
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
![Page 5: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/5.jpg)
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
![Page 6: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/6.jpg)
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
![Page 7: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/7.jpg)
7
OCL Constraint and EA An OCL constraint is an OCL Boolean expression
that evaluates to true or false
![Page 8: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/8.jpg)
8
דוגמא:אילוצים על נישואים
![Page 9: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/9.jpg)
9
EA: 1נישואים אילוץ
![Page 10: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/10.jpg)
10
EA: 2נישואים אילוץ
![Page 11: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/11.jpg)
11
EA: 3נישואים אילוץ
![Page 12: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/12.jpg)
12
EA: 4נישואים אילוץ
![Page 13: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/13.jpg)
13
רשימת הנושאים מבואמרכיבי השפהדוגמאותמקורות
![Page 14: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/14.jpg)
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
![Page 15: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/15.jpg)
15
Operations on Real and Integer Types
![Page 16: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/16.jpg)
16
Operations on String Types
![Page 17: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/17.jpg)
17
Operations on Boolean Types
![Page 18: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/18.jpg)
18
The OCL Collection Hierarchy
![Page 19: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/19.jpg)
19
Operations on all Collections
![Page 20: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/20.jpg)
20
Operations on all Collections
![Page 21: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/21.jpg)
21
Specialized Collection Operations
![Page 22: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/22.jpg)
22
Types of OCL expressions
Expression Type
Syntax Applies to Semantics
invariant Inv: Classifier The invariant must be true for all instances of the classifier
precondition Pre: Operation
Behavioral feature
The precondition must be true before the operation executes
postcondition Post: Operation
Behavioral feature
The precondition must be true after the operation executes
The keyword result refers to the result of the operation
![Page 23: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/23.jpg)
23
Types of OCL expressionsExpression Type
Syntax Applies to Semantics
Query operation body
Body: Query operation
Defines the body of a query operation
Initial value Init: Attribute
Association
end
Defines the initial value of the attribute or the association end
define Def: Classifier Adds variables or helper operations to a context classifier
let let: OCL
expression
Adds local variables to OCL expressions
Derived value Derive: Attribute
Association
end
Defines the derivation rule for the derived attribute or association end
![Page 24: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/24.jpg)
24
רשימת הנושאים מבואמרכיבי השפהדוגמאותמקורות
![Page 25: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/25.jpg)
25
דוגמא
![Page 26: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/26.jpg)
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
![Page 27: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/27.jpg)
27
inv:
1. No account shall be overdrawn by more than 1000$
Context BankAccount
inv balanceValue:
self.balance>-1000
![Page 28: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/28.jpg)
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
![Page 29: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/29.jpg)
29
inv:
3. DepositAccounts shall never be overdrawn
Context DepositAccount
inv balanceValue:
self.balance>=0.0
![Page 30: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/30.jpg)
30
pre: post and @pre
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:
self.balance=self.balance@pre + amount
![Page 31: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/31.jpg)
31
OCL Example: Companies and Employees
![Page 32: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/32.jpg)
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.
![Page 33: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/33.jpg)
33
OCL Example
"If a person is employed at a company, it is not unemployed."
context Company
inv: employee->exists(isUnemployed) = false
![Page 34: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/34.jpg)
34
רשימת הנושאים מבואמרכיבי השפהדוגמאותמקורות
![Page 35: 1 OCL The Role of OCL in UML. 2 רשימת הנושאים מבוא מרכיבי השפה דוגמאות מקורות](https://reader036.vdocuments.us/reader036/viewer/2022062322/56649f0d5503460f94c21304/html5/thumbnails/35.jpg)
35
References Pressman, Roger S. Software Engineering: A Practitioner’s Approach, 6/e. New
York: McGraw-Hill, 2005. Object Constraint Language Specification OMG Available Specification v2.0
May 2006 <http://www.omg.org/cgi-bin/doc?formal/06-05-01.pdf>. http://en.wikipedia.org/wiki/Object_Constraint_Language