SlideShare a Scribd company logo
megaplanet
OCL : An Expression LanguageOCL : An Expression Language
Basic Types, Enumerated Types, Types ConstructorsBasic Types, Enumerated Types, Types Constructors
Expressions, OperationsExpressions, Operations
Operations on collectionsOperations on collections
megaplanet
2
OCL = An Expression LanguageOCL = An Expression Language
No side effectNo side effect
No explicit iterationNo explicit iteration
Like a functional languageLike a functional language
but no functions (in the standard)but no functions (in the standard)
Can serve as aCan serve as a query languagequery language
This first part,
« OCL : An Expression language » is
almost independent from UML
megaplanet
3
TypesTypes
Basic typesBasic types
IntegerInteger
RealReal
BooleanBoolean
StringString
Enumerated typesEnumerated types
MetatypesMetatypes
OclTypeOclType
OclAnyOclAny
OclStateOclState
OclExpressionOclExpression
Types from UMLTypes from UML
classesclasses
associationsassociations
……
Type constructorsType constructors
TupleType( x : T, y : T … )TupleType( x : T, y : T … )
Set(T)Set(T)
OrderedSet(T)OrderedSet(T)
Sequence(T)Sequence(T)
Bag(T)Bag(T)
Collection(T)Collection(T)
megaplanet
4
Syntax of ExpressionsSyntax of Expressions (Simplified)
<const> 12 'hello'
<id> children Residence
<expr> <op> <expr> age>18
self like in python, « this » in java
<exprobj> . <prop> self.chairman.age
<exprobj> . <objprop>(<expr>...) self.chairman.increaseSalary(10)
<exprcoll> -> <collprop>(<expr>...) self.employees->collect(salary)
<package>::<package> … :: <element> like in C++, « . » in python and java
if <expr> then <expr> else <expr> endif if age>18 then 1200 else 50*age endif
let <id> : <type> in <expr> .<expr> let e=x*x+y in (e-20)*1,5
megaplanet
5
ExamplesExamples
self.salary - 100
self.children->isEmpty()
self.children->forall(age>20)
self.getTaxes(1998) / self.children->size()
self.children->select( sex= Sex::male )
self.children->collect(salary)->sum()
self.children.salary->sum()
self.children->union(self.parents)->collect(age)
children
*
Person
sex:Sex
salary:real
age:integer
parents
0..2
getTaxes()
<<enumeration>>
Sex
male
female
megaplanet
6
To be Remembered !To be Remembered !
. to get access to properties of objects
->-> to get access to properties of collectionsto get access to properties of collections
+ some rules to mix collections and objects (see later)
self.taxes(1998) / self.children -> size()
because self
is an object
because self.children
is a collection of objects
megaplanet
7
Integer et RealInteger et Real
IntegerInteger
values :values : 1, -5, 34, 243431, -5, 34, 24343, ..., ...
operations :operations : +, -, *, div, mod, abs, max, min+, -, *, div, mod, abs, max, min
RealReal
values :values : 1.5, 1.341.5, 1.34, ..., ...
operations :operations : +, -, *, /, floor, round, max, min+, -, *, /, floor, round, max, min
Integer type « conforms » to the type Real
megaplanet
8
BooleanBoolean
BooleanBoolean
values :values : truetrue,, falsefalse
operations :operations : notnot,, andand,, oror,, xorxor,, impliesimplies,, if-then-else-endifif-then-else-endif
partial evaluation :partial evaluation :
true oror x always true, even when x is undefined
false andand x always false, even when x is undefined
(age<40 implies salaire>1000) and (age>=40 implies salaire>2000)
if age<40 then salaire > 1000 else salaire > 2000 endif
salaire > (if age<40 then 1000 else 2000 endif)
megaplanet
9
StringString
name = nom.substring(1,1).toUpper().concat(
nom.substring(2,nom.size()).toLower())
Strings are not sequence of Sequence(char) (no char type)
Operations:Operations:
==
ss..sizesize()()
s1s1..concatconcat((s2s2))
s1s1..substringsubstring((i1i1,,i2i2))
ss..toUppertoUpper()()
ss..toLowertoLower()()
Values:Values:
''''
'a sentence''a sentence'
megaplanet
10
EnumerationEnumeration
ValuesValues
Day::TuesdayDay::Tuesday (previous notation:(previous notation: #Tuesday#Tuesday ))
OperatorsOperators
==,, <><>
No ordering relation
<<enumeration>>
Day
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
megaplanet
11
ExamplesExamples
spouse->notEmpty() implies spouse.sex = Sex::female
épouse.sexe < sexe
husband
0..1
Person
sex : Sex
spouse
0..1
No ordering relationNot always
defined
<<enumeration>>
Sex
male
female
megaplanet
12
Element vs. singletonElement vs. singleton
In almost all languagesIn almost all languages
one elementone element ee
from singleton containing this elementfrom singleton containing this element Set{e}Set{e}
self->size() = 1
Implicit conversion in OCLImplicit conversion in OCL element => singletonelement => singleton
when an collection operationwhen an collection operation
is applied to an elementis applied to an element
elemelem ->-> propprop Set{Set{elemelem}->}->propprop
≠
megaplanet
13
CollectionsCollections
General TypeGeneral Type CollectionCollection(( TT ))
Set(Set(TT ))
{unique}{unique} {nonunique}{nonunique}
{unordered}{unordered}
{ordered}{ordered} Sequence(Sequence(TT ))
Bag(Bag(TT ))
OrderedSet(OrderedSet(TT ))
megaplanet
14
Use of collections for role navigationUse of collections for role navigation
object . nomderoleobject . nomderole type:type:
X
1 or 0..1
X
*
X
{ordered} *
X
Set(X)
OrderedSet(X)
X
*{nonunique}
Bag(X)
X
{ordered, nonunique} *
Sequence(X)
megaplanet
15
Collection ExpressionsCollection Expressions
ExamplesExamples
SetSet {{ 'lundi''lundi',, 'mercredi''mercredi',, 'mardi''mardi' }}
BagBag {{ 'lundi''lundi',, 'lundi''lundi',, 'mardi''mardi',, 'lundi''lundi' }}
OrderedSetOrderedSet {{ 1010,, 2020,, 55 }}
SequenceSequence {{ 'lundi''lundi',, 'lundi''lundi',, 'mardi''mardi',, 'lundi''lundi' }}
To specify rangesTo specify ranges
SequenceSequence {{ 1..5, 2..41..5, 2..4 }}
Useful for 'loops' :
Sequence { 0 .. etagesnb-1 } -> forall( i | canStop(i) )
megaplanet
16
Operations on CollectionsOperations on Collections
Cardinality: coll -> size()
Emptyness: coll -> isEmpty()
Non emptyness: coll -> notEmpty()
Occurrence number: coll -> count(elem)
Membership: coll -> includes( elem )
Non membership: coll -> excludes( elem )
Inclusion: coll -> includesAll(coll)
Exclusion: coll -> excludesAll(coll)
Sum (of numbers): coll -> sum()
megaplanet
17
ExamplesExamples
Set { 3, 5, 2, 45, 5 }->size()
Sequence { 1, 2, 45, 9, 3, 9 } ->count(9)
Sequence { 1, 2, 45, 2, 3, 9 } ->includes(45)
Bag { 1, 9, 9, 1 } -> count(9)
c->asSet()->size() = c->size()
c->count(x) = 0
Bag { 1, 9, 0, 1, 2, 9, 1 } -> includesAll( Bag{ 9,1,9} )
megaplanet
18
Operations on SetsOperations on Sets
UnionUnion ens ->ens -> unionunion( ens )( ens )
IntersectionIntersection ens ->ens -> intersectionintersection( ens )( ens )
DifferenceDifference ens1 - ens2ens1 - ens2
Adding an elementAdding an element ens ->ens -> includingincluding(elem)(elem)
Removing an elementRemoving an element ens ->ens -> excludingexcluding(elem)(elem)
Sequence conversionSequence conversion ens ->ens -> asSequence()asSequence()
Bag conversionBag conversion ens ->ens -> asBag()asBag()
Conversion to ordered setConversion to ordered set ens ->ens -> asOrderedSet()asOrderedSet()
megaplanet
19
Filtering: select, reject and anyFiltering: select, reject and any
coll -> select( cond )
select elements satisfying the conditionselect elements satisfying the condition
coll -> reject( cond )
reject elementsreject elements
coll -> any( cond )
selectselect anyany element satisfying the conditionelement satisfying the condition
• non deterministnon determinist
• useful when there is only one elementuseful when there is only one element
• "undefined" if the collection is empty"undefined" if the collection is empty
megaplanet
20
ExamplesExamples
self.children ->select( age>10 and sex = Sex::Male)
self.children ->reject(e : Person | e.children->isEmpty())->notEmpty()
members->any(title='president')
children*
Member
sex : Sexe
age : integer
title : string
parents0..2Club members
*
megaplanet
21
Syntax AlternativesSyntax Alternatives
self.employees->select(age > 50)
self.employees->select( p | p.age>50 )
self.employees->select( p : Person | p.age>50)
Person
age : integer
Company
employees
*
megaplanet
22
forall, exists, oneforall, exists, one
coll ->coll -> forallforall( cond )( cond )
coll ->coll -> existsexists( cond )( cond )
coll ->coll -> oneone( cond )( cond )
self.enfants->forall(age<10)
self.enfants->exists(sexe=Sexe::Masculin)
self.enfants->one(age>=18)
children*
Person
sexe : Sex
age : integer
parents0..2
megaplanet
23
Syntax ComparisonSyntax Comparison
children->forall( p : Person | p.age<10)
∀ c ∈ children . c.age < 10
megaplanet
24
Quantifiers: more about syntaxQuantifiers: more about syntax
It's possible toIt's possible to
give a name to a variablegive a name to a variable
explicit its typeexplicit its type
use various variables at the same timeuse various variables at the same time
self.children->forall( age < self.age )
self.enfants->forall( e | e.age < self.age - 7)
self.children->forall( e : Personne | e.age < self.age - 7)
self.children->exists( e1,e2 | e1.age = e2.age )
self.children->exists( e1,e2 | e1.age = e2.age and e1<>e2 )
self.children->forall( e1,e2 : Personne |
e1 <> e2 implies e1.firstname <> e2.firstname)
children*
Person
age
firstname
megaplanet
25
UnicityUnicity
coll -> isUnique ( expr )
True if all elements return a different value for exprTrue if all elements return a different value for expr
self.children -> isUnique ( firstname )
instead ofinstead of
self.children->forall( p1,p2 : Person |
p1 <> p2 implies p1.firstname <> e2.firstname)
Useful to define the notion of "imported key" for instance
children*
Person
age
firstname
megaplanet
26
isUnique vs. {unique}isUnique vs. {unique}
self.children -> isUnique ( firstname )
children*
Person
age
firstname
{unique}
megaplanet
27
Image of an expression: collectImage of an expression: collect
coll ->coll -> collectcollect( expr )( expr )
"image" of a function (map, apply, ...)
expr evaluated for each element
result in:
a Bag if coll is a Set or a Bag
a Sequence if coll is a Sequence or a OrderedSet
self.enfants->collect(age) = Bag{10,5,10,7}
self.employés->collect(salaire/10)->sum()
children*
Person
age
employees
*
Company Employee
salary
megaplanet
28
Collect: Simplified Syntax!Collect: Simplified Syntax!
.. with a collectionwith a collection ↔↔ collectcollect
children*
Person
age
self.children.age
self.children->collect(age)
megaplanet
29
Collect Possible Duplicates→Collect Possible Duplicates→
The result is a Bag or Sequence because of possible duplicatesThe result is a Bag or Sequence because of possible duplicates
To get a setTo get a set
self.children.age->asSet()
. shortcut very usefull to navigate!. shortcut very usefull to navigate!
self.children.children.cars
children*
Person
age
Cars
cars
**

More Related Content

What's hot

Base NoSql et Python
Base NoSql et PythonBase NoSql et Python
Base NoSql et Python
yboussard
 
Cohesion et couplage
Cohesion et couplage Cohesion et couplage
Cohesion et couplage
Ahmed HARRAK
 
Support de cours Spring M.youssfi
Support de cours Spring  M.youssfiSupport de cours Spring  M.youssfi
Support de cours Spring M.youssfi
ENSET, Université Hassan II Casablanca
 
Java and SPARQL
Java and SPARQLJava and SPARQL
Java and SPARQL
Raji Ghawi
 
Memory Optimization
Memory OptimizationMemory Optimization
Memory OptimizationWei Lin
 
L'API Collector dans tous ses états
L'API Collector dans tous ses étatsL'API Collector dans tous ses états
L'API Collector dans tous ses états
José Paumard
 
Cours python avancé
Cours python avancéCours python avancé
Cours python avancépierrepo
 
stackconf 2021 | Weaviate Vector Search Engine – Introduction
stackconf 2021 | Weaviate Vector Search Engine – Introductionstackconf 2021 | Weaviate Vector Search Engine – Introduction
stackconf 2021 | Weaviate Vector Search Engine – Introduction
NETWAYS
 
Transformer in Computer Vision
Transformer in Computer VisionTransformer in Computer Vision
Transformer in Computer Vision
Dongmin Choi
 
Design patterns
Design patternsDesign patterns
Design patterns
Eric Toguem
 
Introduction à React
Introduction à ReactIntroduction à React
Introduction à React
Abdoulaye Dieng
 
Integration de donnees_etl
Integration de donnees_etlIntegration de donnees_etl
Integration de donnees_etl
horacio lassey
 
introduction à MongoDB
introduction à MongoDBintroduction à MongoDB
introduction à MongoDB
Abdoulaye Dieng
 
Design Pattern introduction
Design Pattern introductionDesign Pattern introduction
Design Pattern introduction
neuros
 
ViT (Vision Transformer) Review [CDM]
ViT (Vision Transformer) Review [CDM]ViT (Vision Transformer) Review [CDM]
ViT (Vision Transformer) Review [CDM]
Dongmin Choi
 
Chap5 diagramme d'etats-transitions
Chap5 diagramme d'etats-transitionsChap5 diagramme d'etats-transitions
Chap5 diagramme d'etats-transitions
Amir Souissi
 
Jena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for JavaJena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for JavaAleksander Pohl
 
Transformation M2M avec ATL
Transformation M2M avec ATL Transformation M2M avec ATL
Transformation M2M avec ATL
Halima Bouabdelli
 
P8 03 presentation
P8 03 presentationP8 03 presentation
P8 03 presentation
rajiasellami
 
Introduction à spring boot
Introduction à spring bootIntroduction à spring boot
Introduction à spring boot
Antoine Rey
 

What's hot (20)

Base NoSql et Python
Base NoSql et PythonBase NoSql et Python
Base NoSql et Python
 
Cohesion et couplage
Cohesion et couplage Cohesion et couplage
Cohesion et couplage
 
Support de cours Spring M.youssfi
Support de cours Spring  M.youssfiSupport de cours Spring  M.youssfi
Support de cours Spring M.youssfi
 
Java and SPARQL
Java and SPARQLJava and SPARQL
Java and SPARQL
 
Memory Optimization
Memory OptimizationMemory Optimization
Memory Optimization
 
L'API Collector dans tous ses états
L'API Collector dans tous ses étatsL'API Collector dans tous ses états
L'API Collector dans tous ses états
 
Cours python avancé
Cours python avancéCours python avancé
Cours python avancé
 
stackconf 2021 | Weaviate Vector Search Engine – Introduction
stackconf 2021 | Weaviate Vector Search Engine – Introductionstackconf 2021 | Weaviate Vector Search Engine – Introduction
stackconf 2021 | Weaviate Vector Search Engine – Introduction
 
Transformer in Computer Vision
Transformer in Computer VisionTransformer in Computer Vision
Transformer in Computer Vision
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Introduction à React
Introduction à ReactIntroduction à React
Introduction à React
 
Integration de donnees_etl
Integration de donnees_etlIntegration de donnees_etl
Integration de donnees_etl
 
introduction à MongoDB
introduction à MongoDBintroduction à MongoDB
introduction à MongoDB
 
Design Pattern introduction
Design Pattern introductionDesign Pattern introduction
Design Pattern introduction
 
ViT (Vision Transformer) Review [CDM]
ViT (Vision Transformer) Review [CDM]ViT (Vision Transformer) Review [CDM]
ViT (Vision Transformer) Review [CDM]
 
Chap5 diagramme d'etats-transitions
Chap5 diagramme d'etats-transitionsChap5 diagramme d'etats-transitions
Chap5 diagramme d'etats-transitions
 
Jena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for JavaJena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for Java
 
Transformation M2M avec ATL
Transformation M2M avec ATL Transformation M2M avec ATL
Transformation M2M avec ATL
 
P8 03 presentation
P8 03 presentationP8 03 presentation
P8 03 presentation
 
Introduction à spring boot
Introduction à spring bootIntroduction à spring boot
Introduction à spring boot
 

Similar to UML OCL : An Expression Language - Core -- 29

Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
Oswald Campesato
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming ii
Prashant Kalkar
 
Privet Kotlin (Windy City DevFest)
Privet Kotlin (Windy City DevFest)Privet Kotlin (Windy City DevFest)
Privet Kotlin (Windy City DevFest)
Cody Engel
 
Python_ 3 CheatSheet
Python_ 3 CheatSheetPython_ 3 CheatSheet
Python_ 3 CheatSheet
Dr. Volkan OBAN
 
Types and Immutability: why you should care
Types and Immutability: why you should careTypes and Immutability: why you should care
Types and Immutability: why you should care
Jean Carlo Emer
 
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and Cats
Philip Schwarz
 
Extreme Swift
Extreme SwiftExtreme Swift
Extreme Swift
Movel
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
Utkarsh Sengar
 
Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocaml
pramode_ce
 
The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.6 book - Part 183 of 189The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.6 book - Part 183 of 189
Mahmoud Samir Fayed
 
Python3 cheatsheet
Python3 cheatsheetPython3 cheatsheet
Python3 cheatsheet
Gil Cohen
 
The Ring programming language version 1.4 book - Part 29 of 30
The Ring programming language version 1.4 book - Part 29 of 30The Ring programming language version 1.4 book - Part 29 of 30
The Ring programming language version 1.4 book - Part 29 of 30
Mahmoud Samir Fayed
 
7 Habits For a More Functional Swift
7 Habits For a More Functional Swift7 Habits For a More Functional Swift
7 Habits For a More Functional Swift
Jason Larsen
 
Kotlin from-scratch 2 - functions
Kotlin from-scratch 2 - functionsKotlin from-scratch 2 - functions
Kotlin from-scratch 2 - functions
Franco Lombardo
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids Applied
Susan Potter
 
Python3
Python3Python3
Mementopython3 english
Mementopython3 englishMementopython3 english
Mementopython3 english
ssuser442080
 
The Ring programming language version 1.5.2 book - Part 24 of 181
The Ring programming language version 1.5.2 book - Part 24 of 181The Ring programming language version 1.5.2 book - Part 24 of 181
The Ring programming language version 1.5.2 book - Part 24 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 33 of 181
The Ring programming language version 1.5.2 book - Part 33 of 181The Ring programming language version 1.5.2 book - Part 33 of 181
The Ring programming language version 1.5.2 book - Part 33 of 181
Mahmoud Samir Fayed
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
Muthu Vinayagam
 

Similar to UML OCL : An Expression Language - Core -- 29 (20)

Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming ii
 
Privet Kotlin (Windy City DevFest)
Privet Kotlin (Windy City DevFest)Privet Kotlin (Windy City DevFest)
Privet Kotlin (Windy City DevFest)
 
Python_ 3 CheatSheet
Python_ 3 CheatSheetPython_ 3 CheatSheet
Python_ 3 CheatSheet
 
Types and Immutability: why you should care
Types and Immutability: why you should careTypes and Immutability: why you should care
Types and Immutability: why you should care
 
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and Cats
 
Extreme Swift
Extreme SwiftExtreme Swift
Extreme Swift
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
 
Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocaml
 
The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.6 book - Part 183 of 189The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.6 book - Part 183 of 189
 
Python3 cheatsheet
Python3 cheatsheetPython3 cheatsheet
Python3 cheatsheet
 
The Ring programming language version 1.4 book - Part 29 of 30
The Ring programming language version 1.4 book - Part 29 of 30The Ring programming language version 1.4 book - Part 29 of 30
The Ring programming language version 1.4 book - Part 29 of 30
 
7 Habits For a More Functional Swift
7 Habits For a More Functional Swift7 Habits For a More Functional Swift
7 Habits For a More Functional Swift
 
Kotlin from-scratch 2 - functions
Kotlin from-scratch 2 - functionsKotlin from-scratch 2 - functions
Kotlin from-scratch 2 - functions
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids Applied
 
Python3
Python3Python3
Python3
 
Mementopython3 english
Mementopython3 englishMementopython3 english
Mementopython3 english
 
The Ring programming language version 1.5.2 book - Part 24 of 181
The Ring programming language version 1.5.2 book - Part 24 of 181The Ring programming language version 1.5.2 book - Part 24 of 181
The Ring programming language version 1.5.2 book - Part 24 of 181
 
The Ring programming language version 1.5.2 book - Part 33 of 181
The Ring programming language version 1.5.2 book - Part 33 of 181The Ring programming language version 1.5.2 book - Part 33 of 181
The Ring programming language version 1.5.2 book - Part 33 of 181
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
 

More from megaplanet20

UML OCL : Cheat Sheet - 10
UML OCL : Cheat Sheet - 10UML OCL : Cheat Sheet - 10
UML OCL : Cheat Sheet - 10
megaplanet20
 
IDM : Vision Globale - Introduction -- 9
IDM : Vision Globale - Introduction -- 9IDM : Vision Globale - Introduction -- 9
IDM : Vision Globale - Introduction -- 9
megaplanet20
 
UML OCL : Liaison avecUML -- 24
UML OCL : Liaison avecUML -- 24UML OCL : Liaison avecUML -- 24
UML OCL : Liaison avecUML -- 24
megaplanet20
 
UML : Diagrammes de cas d'utilisation -- Problemes recurrents -- 20
UML : Diagrammes de cas d'utilisation -- Problemes recurrents -- 20UML : Diagrammes de cas d'utilisation -- Problemes recurrents -- 20
UML : Diagrammes de cas d'utilisation -- Problemes recurrents -- 20
megaplanet20
 
UML : Diagrammes de cas d'utilisation -- modele detaille -- 15
UML : Diagrammes de cas d'utilisation -- modele detaille -- 15UML : Diagrammes de cas d'utilisation -- modele detaille -- 15
UML : Diagrammes de cas d'utilisation -- modele detaille -- 15
megaplanet20
 
Uml : Diagrammes de Cas dutilisation -- Modele preliminaire -- 23
Uml : Diagrammes de Cas dutilisation -- Modele preliminaire -- 23Uml : Diagrammes de Cas dutilisation -- Modele preliminaire -- 23
Uml : Diagrammes de Cas dutilisation -- Modele preliminaire -- 23
megaplanet20
 
Uml: Diagrammes de classes -- Concepts avances --- 27
Uml: Diagrammes de classes -- Concepts avances --- 27Uml: Diagrammes de classes -- Concepts avances --- 27
Uml: Diagrammes de classes -- Concepts avances --- 27
megaplanet20
 
Uml: Diagrammes de classes -- Concepts De Base 41
Uml: Diagrammes de classes -- Concepts De Base 41Uml: Diagrammes de classes -- Concepts De Base 41
Uml: Diagrammes de classes -- Concepts De Base 41
megaplanet20
 

More from megaplanet20 (8)

UML OCL : Cheat Sheet - 10
UML OCL : Cheat Sheet - 10UML OCL : Cheat Sheet - 10
UML OCL : Cheat Sheet - 10
 
IDM : Vision Globale - Introduction -- 9
IDM : Vision Globale - Introduction -- 9IDM : Vision Globale - Introduction -- 9
IDM : Vision Globale - Introduction -- 9
 
UML OCL : Liaison avecUML -- 24
UML OCL : Liaison avecUML -- 24UML OCL : Liaison avecUML -- 24
UML OCL : Liaison avecUML -- 24
 
UML : Diagrammes de cas d'utilisation -- Problemes recurrents -- 20
UML : Diagrammes de cas d'utilisation -- Problemes recurrents -- 20UML : Diagrammes de cas d'utilisation -- Problemes recurrents -- 20
UML : Diagrammes de cas d'utilisation -- Problemes recurrents -- 20
 
UML : Diagrammes de cas d'utilisation -- modele detaille -- 15
UML : Diagrammes de cas d'utilisation -- modele detaille -- 15UML : Diagrammes de cas d'utilisation -- modele detaille -- 15
UML : Diagrammes de cas d'utilisation -- modele detaille -- 15
 
Uml : Diagrammes de Cas dutilisation -- Modele preliminaire -- 23
Uml : Diagrammes de Cas dutilisation -- Modele preliminaire -- 23Uml : Diagrammes de Cas dutilisation -- Modele preliminaire -- 23
Uml : Diagrammes de Cas dutilisation -- Modele preliminaire -- 23
 
Uml: Diagrammes de classes -- Concepts avances --- 27
Uml: Diagrammes de classes -- Concepts avances --- 27Uml: Diagrammes de classes -- Concepts avances --- 27
Uml: Diagrammes de classes -- Concepts avances --- 27
 
Uml: Diagrammes de classes -- Concepts De Base 41
Uml: Diagrammes de classes -- Concepts De Base 41Uml: Diagrammes de classes -- Concepts De Base 41
Uml: Diagrammes de classes -- Concepts De Base 41
 

Recently uploaded

How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 

Recently uploaded (20)

How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 

UML OCL : An Expression Language - Core -- 29

  • 1. megaplanet OCL : An Expression LanguageOCL : An Expression Language Basic Types, Enumerated Types, Types ConstructorsBasic Types, Enumerated Types, Types Constructors Expressions, OperationsExpressions, Operations Operations on collectionsOperations on collections
  • 2. megaplanet 2 OCL = An Expression LanguageOCL = An Expression Language No side effectNo side effect No explicit iterationNo explicit iteration Like a functional languageLike a functional language but no functions (in the standard)but no functions (in the standard) Can serve as aCan serve as a query languagequery language This first part, « OCL : An Expression language » is almost independent from UML
  • 3. megaplanet 3 TypesTypes Basic typesBasic types IntegerInteger RealReal BooleanBoolean StringString Enumerated typesEnumerated types MetatypesMetatypes OclTypeOclType OclAnyOclAny OclStateOclState OclExpressionOclExpression Types from UMLTypes from UML classesclasses associationsassociations …… Type constructorsType constructors TupleType( x : T, y : T … )TupleType( x : T, y : T … ) Set(T)Set(T) OrderedSet(T)OrderedSet(T) Sequence(T)Sequence(T) Bag(T)Bag(T) Collection(T)Collection(T)
  • 4. megaplanet 4 Syntax of ExpressionsSyntax of Expressions (Simplified) <const> 12 'hello' <id> children Residence <expr> <op> <expr> age>18 self like in python, « this » in java <exprobj> . <prop> self.chairman.age <exprobj> . <objprop>(<expr>...) self.chairman.increaseSalary(10) <exprcoll> -> <collprop>(<expr>...) self.employees->collect(salary) <package>::<package> … :: <element> like in C++, « . » in python and java if <expr> then <expr> else <expr> endif if age>18 then 1200 else 50*age endif let <id> : <type> in <expr> .<expr> let e=x*x+y in (e-20)*1,5
  • 5. megaplanet 5 ExamplesExamples self.salary - 100 self.children->isEmpty() self.children->forall(age>20) self.getTaxes(1998) / self.children->size() self.children->select( sex= Sex::male ) self.children->collect(salary)->sum() self.children.salary->sum() self.children->union(self.parents)->collect(age) children * Person sex:Sex salary:real age:integer parents 0..2 getTaxes() <<enumeration>> Sex male female
  • 6. megaplanet 6 To be Remembered !To be Remembered ! . to get access to properties of objects ->-> to get access to properties of collectionsto get access to properties of collections + some rules to mix collections and objects (see later) self.taxes(1998) / self.children -> size() because self is an object because self.children is a collection of objects
  • 7. megaplanet 7 Integer et RealInteger et Real IntegerInteger values :values : 1, -5, 34, 243431, -5, 34, 24343, ..., ... operations :operations : +, -, *, div, mod, abs, max, min+, -, *, div, mod, abs, max, min RealReal values :values : 1.5, 1.341.5, 1.34, ..., ... operations :operations : +, -, *, /, floor, round, max, min+, -, *, /, floor, round, max, min Integer type « conforms » to the type Real
  • 8. megaplanet 8 BooleanBoolean BooleanBoolean values :values : truetrue,, falsefalse operations :operations : notnot,, andand,, oror,, xorxor,, impliesimplies,, if-then-else-endifif-then-else-endif partial evaluation :partial evaluation : true oror x always true, even when x is undefined false andand x always false, even when x is undefined (age<40 implies salaire>1000) and (age>=40 implies salaire>2000) if age<40 then salaire > 1000 else salaire > 2000 endif salaire > (if age<40 then 1000 else 2000 endif)
  • 9. megaplanet 9 StringString name = nom.substring(1,1).toUpper().concat( nom.substring(2,nom.size()).toLower()) Strings are not sequence of Sequence(char) (no char type) Operations:Operations: == ss..sizesize()() s1s1..concatconcat((s2s2)) s1s1..substringsubstring((i1i1,,i2i2)) ss..toUppertoUpper()() ss..toLowertoLower()() Values:Values: '''' 'a sentence''a sentence'
  • 10. megaplanet 10 EnumerationEnumeration ValuesValues Day::TuesdayDay::Tuesday (previous notation:(previous notation: #Tuesday#Tuesday )) OperatorsOperators ==,, <><> No ordering relation <<enumeration>> Day Monday Tuesday Wednesday Thursday Friday Saturday Sunday
  • 11. megaplanet 11 ExamplesExamples spouse->notEmpty() implies spouse.sex = Sex::female épouse.sexe < sexe husband 0..1 Person sex : Sex spouse 0..1 No ordering relationNot always defined <<enumeration>> Sex male female
  • 12. megaplanet 12 Element vs. singletonElement vs. singleton In almost all languagesIn almost all languages one elementone element ee from singleton containing this elementfrom singleton containing this element Set{e}Set{e} self->size() = 1 Implicit conversion in OCLImplicit conversion in OCL element => singletonelement => singleton when an collection operationwhen an collection operation is applied to an elementis applied to an element elemelem ->-> propprop Set{Set{elemelem}->}->propprop ≠
  • 13. megaplanet 13 CollectionsCollections General TypeGeneral Type CollectionCollection(( TT )) Set(Set(TT )) {unique}{unique} {nonunique}{nonunique} {unordered}{unordered} {ordered}{ordered} Sequence(Sequence(TT )) Bag(Bag(TT )) OrderedSet(OrderedSet(TT ))
  • 14. megaplanet 14 Use of collections for role navigationUse of collections for role navigation object . nomderoleobject . nomderole type:type: X 1 or 0..1 X * X {ordered} * X Set(X) OrderedSet(X) X *{nonunique} Bag(X) X {ordered, nonunique} * Sequence(X)
  • 15. megaplanet 15 Collection ExpressionsCollection Expressions ExamplesExamples SetSet {{ 'lundi''lundi',, 'mercredi''mercredi',, 'mardi''mardi' }} BagBag {{ 'lundi''lundi',, 'lundi''lundi',, 'mardi''mardi',, 'lundi''lundi' }} OrderedSetOrderedSet {{ 1010,, 2020,, 55 }} SequenceSequence {{ 'lundi''lundi',, 'lundi''lundi',, 'mardi''mardi',, 'lundi''lundi' }} To specify rangesTo specify ranges SequenceSequence {{ 1..5, 2..41..5, 2..4 }} Useful for 'loops' : Sequence { 0 .. etagesnb-1 } -> forall( i | canStop(i) )
  • 16. megaplanet 16 Operations on CollectionsOperations on Collections Cardinality: coll -> size() Emptyness: coll -> isEmpty() Non emptyness: coll -> notEmpty() Occurrence number: coll -> count(elem) Membership: coll -> includes( elem ) Non membership: coll -> excludes( elem ) Inclusion: coll -> includesAll(coll) Exclusion: coll -> excludesAll(coll) Sum (of numbers): coll -> sum()
  • 17. megaplanet 17 ExamplesExamples Set { 3, 5, 2, 45, 5 }->size() Sequence { 1, 2, 45, 9, 3, 9 } ->count(9) Sequence { 1, 2, 45, 2, 3, 9 } ->includes(45) Bag { 1, 9, 9, 1 } -> count(9) c->asSet()->size() = c->size() c->count(x) = 0 Bag { 1, 9, 0, 1, 2, 9, 1 } -> includesAll( Bag{ 9,1,9} )
  • 18. megaplanet 18 Operations on SetsOperations on Sets UnionUnion ens ->ens -> unionunion( ens )( ens ) IntersectionIntersection ens ->ens -> intersectionintersection( ens )( ens ) DifferenceDifference ens1 - ens2ens1 - ens2 Adding an elementAdding an element ens ->ens -> includingincluding(elem)(elem) Removing an elementRemoving an element ens ->ens -> excludingexcluding(elem)(elem) Sequence conversionSequence conversion ens ->ens -> asSequence()asSequence() Bag conversionBag conversion ens ->ens -> asBag()asBag() Conversion to ordered setConversion to ordered set ens ->ens -> asOrderedSet()asOrderedSet()
  • 19. megaplanet 19 Filtering: select, reject and anyFiltering: select, reject and any coll -> select( cond ) select elements satisfying the conditionselect elements satisfying the condition coll -> reject( cond ) reject elementsreject elements coll -> any( cond ) selectselect anyany element satisfying the conditionelement satisfying the condition • non deterministnon determinist • useful when there is only one elementuseful when there is only one element • "undefined" if the collection is empty"undefined" if the collection is empty
  • 20. megaplanet 20 ExamplesExamples self.children ->select( age>10 and sex = Sex::Male) self.children ->reject(e : Person | e.children->isEmpty())->notEmpty() members->any(title='president') children* Member sex : Sexe age : integer title : string parents0..2Club members *
  • 21. megaplanet 21 Syntax AlternativesSyntax Alternatives self.employees->select(age > 50) self.employees->select( p | p.age>50 ) self.employees->select( p : Person | p.age>50) Person age : integer Company employees *
  • 22. megaplanet 22 forall, exists, oneforall, exists, one coll ->coll -> forallforall( cond )( cond ) coll ->coll -> existsexists( cond )( cond ) coll ->coll -> oneone( cond )( cond ) self.enfants->forall(age<10) self.enfants->exists(sexe=Sexe::Masculin) self.enfants->one(age>=18) children* Person sexe : Sex age : integer parents0..2
  • 23. megaplanet 23 Syntax ComparisonSyntax Comparison children->forall( p : Person | p.age<10) ∀ c ∈ children . c.age < 10
  • 24. megaplanet 24 Quantifiers: more about syntaxQuantifiers: more about syntax It's possible toIt's possible to give a name to a variablegive a name to a variable explicit its typeexplicit its type use various variables at the same timeuse various variables at the same time self.children->forall( age < self.age ) self.enfants->forall( e | e.age < self.age - 7) self.children->forall( e : Personne | e.age < self.age - 7) self.children->exists( e1,e2 | e1.age = e2.age ) self.children->exists( e1,e2 | e1.age = e2.age and e1<>e2 ) self.children->forall( e1,e2 : Personne | e1 <> e2 implies e1.firstname <> e2.firstname) children* Person age firstname
  • 25. megaplanet 25 UnicityUnicity coll -> isUnique ( expr ) True if all elements return a different value for exprTrue if all elements return a different value for expr self.children -> isUnique ( firstname ) instead ofinstead of self.children->forall( p1,p2 : Person | p1 <> p2 implies p1.firstname <> e2.firstname) Useful to define the notion of "imported key" for instance children* Person age firstname
  • 26. megaplanet 26 isUnique vs. {unique}isUnique vs. {unique} self.children -> isUnique ( firstname ) children* Person age firstname {unique}
  • 27. megaplanet 27 Image of an expression: collectImage of an expression: collect coll ->coll -> collectcollect( expr )( expr ) "image" of a function (map, apply, ...) expr evaluated for each element result in: a Bag if coll is a Set or a Bag a Sequence if coll is a Sequence or a OrderedSet self.enfants->collect(age) = Bag{10,5,10,7} self.employés->collect(salaire/10)->sum() children* Person age employees * Company Employee salary
  • 28. megaplanet 28 Collect: Simplified Syntax!Collect: Simplified Syntax! .. with a collectionwith a collection ↔↔ collectcollect children* Person age self.children.age self.children->collect(age)
  • 29. megaplanet 29 Collect Possible Duplicates→Collect Possible Duplicates→ The result is a Bag or Sequence because of possible duplicatesThe result is a Bag or Sequence because of possible duplicates To get a setTo get a set self.children.age->asSet() . shortcut very usefull to navigate!. shortcut very usefull to navigate! self.children.children.cars children* Person age Cars cars **