SlideShare a Scribd company logo
LANGUAGE SYNTAX: NAVIGATION
• Context instance
– context Person
• Accessing attributes
– self.age
• Association ends
– Navigate to the opposite association end using role names
self.employer – Return value is of type Company
– Navigation often results into a set of objects – Example
context Company
self.employees – Return value is of type Set (Person)
Person
age : int
Company
employees employer
* 1
 What does c.employees.employer return?
EXAMPLE 1: NAVIGATION (1)
• self.persons  {Person p1, Person p2}
• self.persons.name  {jack, lisa}
• self.persons.age  {30, 22}
Person
name: String
age: int
parent
children
1
0..*
p1:Person
name = „jack“
age = 30
Administration
2
*
persons
p2:Person
name = „lisa“
age = 22
v:Administration
context Administration:
EXAMPLE 1: NAVIGATION (2)
• self.persons.children  {p3, p4,p3, p4} // returned as
flattened bag
• self.persons.children.parent  {p1, p2,p1, p2, ...}
• self.persons.car.type  {“audi“}
Person
name: String
age: int
parent
children
1
0..*
p1:Person
name = „jack“
age = 30
Administration
2
*
persons
p2:Person
name = „lisa“
age = 22
v:Administration
context Administration:
p3:Person
name = „mick“
age = 1
p4:Person
name = „paul“
age = 2
Car
type: String
*
1
a1:Car
type=„audi“
Kinder:
Eltern:
OCL TYPES (MM VIEW)
OCLType
TupleType
ModelElementType
DataType
PrimitiveType
CollectionType
AnyType
VoidType
String Boolean Integer Real
OrderedSetType SequenceType BagType SetType
OCL TYPES (A FEATURE MODEL
VIEW)
OPERATIONS FOR
PRIMITIVE/PREDEFINED TYPES
 Note that an OrderedSet is not a Set!
OPERATIONS FOR
PRIMITIVE/PREDEFINED TYPES
Simple type Predefined operations
Integer *, +, -, /, abs(), …
Real *, +, -, /, floor(), …
Boolean and, or, xor, not, implies
String concat(), size(), substring(), …
• Predefined simple types
• Integer {Z}
• Real {R}
• Boolean {true, false}
• String {ASCII, Unicode}
OPERATIONS FOR OCLANY
Operation Explanation of result
=(obj2:OclAny):Boolean True, if obj2 and obj reference the same object
oclIsTypeOf(type:OclType):Boolean
oclIsKindOf(type:OclType):
Boolean
oclAsType(type:Ocltype):
Type
The result is obj of type type, or undefined, if the current
type of obj is not type or a direct or indirect subtype of it
(casting).
• OclAny - Supertype of all primitive types
• Operations are inherited by all other types.
• Operations ofOclAny (extract)
• Receiving object is denoted by obj
OPERATIONS FOR OCLANY
• oclIsKindOf vs. oclIsTypeOf
9
Person
Student Professor
context Person
self.oclIsKindOf(Person) : true
self.oclIsTypeOf(Person) : true
self.oclIsKindOf(Student) : false
self.oclIsTypeOf(Student) : false
context Student
self.oclIsKindOf(Person) : true
self.oclIsTypeOf(Person) : false
self.oclIsKindOf(Student) : true
self.oclIsTypeOf(Student) : true
self.oclIsKindOf(Professor) : false
self.oclIsTypeOf(Professor) : false
 Can you guess the difference?
OCLVOID
• OCLVoid includes the null value (and therefore all supertypes of
OCLVoid)
• Examples
null:OCLVoid
ada.discount=null : Boolean
branch42.address=null : Boolean
1/0=null : Boolean
(1/0).oclIsUndefined=true : Boolean
42.oclIsUndefined=false : Boolean
Set{’800-275-2273’,’800-694-7466’,null} : Set(String)
3-VALUED LOGIC FOR OCL
b | not(b)
------+-------
null | null
false | true
true | false
| b2 | b2
b1 or b2 | null false true b1 and b2 | null false true
---------+----------------- ----------+------------------
null | null null true null | null false null
b1 false | null false true b1 false | false false false
true | true true true true | null false true
| b2 | b2
b1 xor b2 | null false true b1 implies b2 | null false true
----------+------------------ --------------+------------------
null | null null null null | null null true
b1 false | null false true b1 false | true true true
true | null true false true | null false true
| b2 | b2
b1 = b2 | null false true b1 <> b2 | null false true
----------+------------------ ---------+------------------
null | true false false null | false true true
b1 false | false true false b1 false | true false true
true | false false true true | true true false
OPERATIONS FOR COLLECTIONS
Operation Explanation of result
size():Integer Number of elements in coll
includes(obj:OclAny):Boolean True, if obj exists in coll
isEmpty:Boolean True, if coll contains no elements
sum:T
Sum of all elements in coll
Elements have to be of type Integer or Real
• Collection is an abstract supertype for all set types
• Specification of the mutual operations
• Set, Bag, Sequence, OrderedSet inherit these operations
• Caution: Operations with a return value of a set-valued type create a new collection (no side effects)
• Syntax: v -> op(…) – Example: {1, 2, 3} -> size()
OPERATIONEN FOR SET/BAG
Operation Explanation of result
union(set2:Set(T)):Set(T) Union of set and set2
intersection(set2:Set(T)):Set(T) Intersection of set and set2
difference(set2:Set(T)):Set() Difference set; elements of set, which do not consist in set2
symmetricDifference(set2:Set(T)):
Set(T)
Set of all elements, which are either in set or in set2, but do
not exist in both sets at the same time
• Set and Bag define additional operations
• Generally based on theory of set concepts
• Operations of Set (extract)
• Receiving object is denoted by set
Operations of Bag (extract)
Operation Explanation of result
union(bag2:Bag(T)):Bag(T) Union of bag and bag2
intersection(bag2:Bag(T)): Bag(T) Intersection of bag and bag2
A∩B
B
A
AB BA
OPERATIONS FOR
ORDEREDSET/SEQUENCE
Operation Explanation of result
first:T First element of orderedSet
last:T Last element of orderedSet
at(i:Integer):T Element on index i of orderedSet
subOrderedSet(lower:Integer,
upper:Integer):OrderedSet(T)
Subset of orderedSet, all elements of orderedSet including
the element on position lower and the element on position
upper
insertAt(index:Integer,object:T)
:OrderedSet(T)
Result is a copy of the orderedSet, including the element
object at the position index
• OrderedSet and Sequences define additional operations
• Allow access or modification through an Index
• Operations of OrderedSet (extract)
• Receiving object is denoted by orderedSet
• Operations of Sequence
• Analogous to the operations of OrderedSet
0 1 2 3 … n
ITERATOR-BASED OPERATIONS
• OCL defines operations for Collections using Iterators
– Projection of new Collections out of existing ones
– Compact declarative specification instead of imperative algorithms
• Predefined Operations
– select(exp) : Collection
– reject(exp) : Collection
– collect(exp) : Collection
– forAll(exp) : Boolean
– exists(exp) : Boolean
– isUnique(exp) : Boolean
• iterate(…) – Iterate over all elements of a Collection
– Generic operation
– Predefined operations are defined with iterate(…)
15
SELECT / REJECT
• Select and Reject return subsets of collections
• Iterate over the complete collection and collect elements
• Select
• Result: Subset of collection, including elements where
booleanExpr is true
• Reject
• Result: Subset of collection, including elements where
booleanExpr is false
collection -> select( v : Type | booleanExp(v) )
collection -> select( v | booleanExp(v) )
collection -> select( booleanExp )
collection-> reject(v : Type | booleanExp(v))
 Do we need a reject operation?
SELECT OPERATION
context Company inv:
self.employee -> select(e : Employee | e.age>50) ->
notEmpty()
List persons<Person> = new List();
for ( Iterator<Person> iter = comp.getEmployee();
iter.hasNext() ){
Person p = iter.next();
if ( p.age > 50 ){
persons.add(p);
}
}
Java 5
OCL
COLLECT OPERATION
• Collect-Operation returns a new collection from an existing one.
• Result of collect always Bag<T>.T defines the type of the property to be collected
• Example
• self.employees -> collect(age) – Return type: Bag(Integer)
• Short notation for collect: self.employees.age
collection -> collect( v : Type | exp(v) )
collection -> collect( v | exp(v) )
collection -> collect( exp )
SEMANTICS OF THE COLLECT
OPERATION
context Company inv:
self.employee ->collect(birthdate) -> size() > 3
List birthdate<Integer> = new List();
for ( Iterator<Person> iter = comp.getEmployee();
iter.hasNext() ){
birthdate.add(iter.next().getBirthdate());
}
Java 5
OCL
context Company inv:
self.employee -> collect(birthdate) -> asSet()
OCL
Bag
(with duplicates)
Set
(without
duplicates)
ITERATOR-BASED OPERATIONS
• ForAll checks, if all elements of a collection evaluate to true. Example:
self.employees -> forAll(age > 18)
• Nesting of forAll-Calls (Cartesian Product)
• Alternative: Use of multiple iteratores
• Exists checks, if at least one element evaluates to true
• Self.employees -> exists(e: Employee | e.isManager = true)
collection -> forAll( v : Type | booleanExp(v) )
collection -> forAll( v | booleanExp(v) )
collection -> forAll( booleanExp )
context Company inv:
self.employee->forAll (e1 | self.employee -> forAll (e2 |
e1 <> e2 implies e1.id <> e2.id))
context Company inv:
self.employee -> forAll (e1, e2 | e1 <> e2 implies e1.id <> e2.id))
ITERATE
• Iterate is the generic form of all iterator-based operations
• Syntax
collection -> iterate( elem : Typ; acc : Typ =
<initExp> | exp(elem, acc) )
• Variable elem is a typed Iterator
• Variable acc is a typed Accumulator
• Gets assigned initial value initExp
• exp(elem, acc) is a function to calculate acc
• collection -> collect( x : T | x.property )
-- semantically equivalent to:
collection -> iterate( x : T; acc : T2 = Bag{} | acc -> including(x.property) )
ITERATE
• Example
– Set{1, 2, 3} -> iterate(i:Integer, a:Integer=0 | a+i)
– Result: 6
collection -> iterate(x : T; acc : T2 = value | acc -> u(acc, x)
iterate (coll : T, acc : T2 = value){
acc=value;
for( Iterator<T> iter =
coll.getElements(); iter.hasNext(); ){
T elem = iter.next();
acc = u(elem, acc);
}
}
Java 5
OCL
TUPLE TYPES
• Tuple types are structured created with the keyword
Tuple and by additionally specifying part names and part
values.
• Tuples and collections are orthogonal
Set{Tuple{name:’Ada’,emails:Set{’ada@acm’,’ada@i
bm’}},Tuple{name:’Bob’,emails:Sequence{’bob@o
mg’,’bob@sun’}}} :
Set(Tuple(emails:Collection(String),name:String))
23
NULL VALUES
• 0<>null ?
• ’’<>null ?
• ’null’<>null ?
• ’NULL’<>null ?
• ’Null’<>null ?
24
 All true, null is a value different from all the others
COLLECTIONS
© AtlanMod - atlanmod-contact@mines-nantes.fr
25
COLLECTIONS
• Sets are insensible to insertion order and frequency
• Ordered Stes are sensible to order, insensible to
frequency
• Bags are sensible to frequency, insensible to order
• Sequence are sensible to both
© AtlanMod - atlanmod-contact@mines-nantes.fr
26
EXAMPLES OF COLLECTIONS
• Set{7,8}=Set{}->including(8)->including(7)
Bag{7,8,7}=Bag{8}->including(7)->including(7)
Sequence{7,8,7}=Sequence{7,8}->including(7)
OrderedSet{7,8}=OrderedSet{7}->including(8)->including(7)
Set{7,8}->excluding(8)=Set{7}
Bag{7,8,7}->excluding(7)=Bag{8}
Sequence{7,8,7}->excluding(7)=Sequence{8}
OrderedSet{9,6,7,8,6,7}->excluding(6)=OrderedSet{9,7,8}
© AtlanMod - atlanmod-contact@mines-nantes.fr
27
COLLECTION CASTING
• Some ambiguos conversions
• Sequence{8,7,7,8}->asSet() = Set{7,8} :
• Sequence{8,7,7,8}->asBag() = Bag{7,7,8,8}
• Set{8,7,7,8}->asSequence()
? Sequence{7,8}
?Sequence{8,7}
28
 Implementator’s decision!!
 Also others like :
 Set{7,8,9}->any(true)
COLLECTION EQUALITY
• Set{7,8} = Set{8,7,7}
• Set{7,8} = Bag{7,8}
• OrderedSet{8,9} = Sequence{8,9}
• OrderedSet{7,8,8} = OrderedSet{7,8,7}
• OrderedSet{7,9,8} = OrderedSet{9,7,8}
© AtlanMod - atlanmod-contact@mines-nantes.fr
29

More Related Content

Similar to OclApunteNavegacion.ppt

12 - Conditions and Loops
12 - Conditions and Loops12 - Conditions and Loops
12 - Conditions and Loops
The World of Smalltalk
 
Collections
CollectionsCollections
Collections
bsurya1989
 
Collections in java
Collections in javaCollections in java
Collections in java
kejpretkopet
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
Binoj T E
 
02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt
Yonas D. Ebren
 
UML OCL : An Expression Language - Core -- 29
UML OCL : An Expression Language - Core -- 29UML OCL : An Expression Language - Core -- 29
UML OCL : An Expression Language - Core -- 29
megaplanet20
 
05-stack_queue.ppt
05-stack_queue.ppt05-stack_queue.ppt
05-stack_queue.ppt
Sarojkumari55
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
TechMagic
 
Scala intro workshop
Scala intro workshopScala intro workshop
Scala intro workshop
Fredrik Vraalsen
 
Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicox
David Rodenas
 
.Net Collection Classes Deep Dive - Rocksolid Tour 2013
.Net Collection Classes Deep Dive  - Rocksolid Tour 2013.Net Collection Classes Deep Dive  - Rocksolid Tour 2013
.Net Collection Classes Deep Dive - Rocksolid Tour 2013
Gary Short
 
科特林λ學
科特林λ學科特林λ學
科特林λ學
彥彬 洪
 
Arrays
ArraysArrays
Arrays
Faisal Aziz
 
eviewsOLSMLE
eviewsOLSMLEeviewsOLSMLE
eviewsOLSMLE
Elmar Mertens
 
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#
Rohit Rao
 
Scala Back to Basics: Type Classes
Scala Back to Basics: Type ClassesScala Back to Basics: Type Classes
Scala Back to Basics: Type Classes
Tomer Gabel
 
DotNet programming & Practices
DotNet programming & PracticesDotNet programming & Practices
DotNet programming & Practices
Dev Raj Gautam
 
Introduction to Ruby Programming Language
Introduction to Ruby Programming LanguageIntroduction to Ruby Programming Language
Introduction to Ruby Programming Language
Nicolò Calcavecchia
 
My lecture stack_queue_operation
My lecture stack_queue_operationMy lecture stack_queue_operation
My lecture stack_queue_operation
Senthil Kumar
 
Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript core
Web Zhao
 

Similar to OclApunteNavegacion.ppt (20)

12 - Conditions and Loops
12 - Conditions and Loops12 - Conditions and Loops
12 - Conditions and Loops
 
Collections
CollectionsCollections
Collections
 
Collections in java
Collections in javaCollections in java
Collections in java
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
 
02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt
 
UML OCL : An Expression Language - Core -- 29
UML OCL : An Expression Language - Core -- 29UML OCL : An Expression Language - Core -- 29
UML OCL : An Expression Language - Core -- 29
 
05-stack_queue.ppt
05-stack_queue.ppt05-stack_queue.ppt
05-stack_queue.ppt
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
 
Scala intro workshop
Scala intro workshopScala intro workshop
Scala intro workshop
 
Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicox
 
.Net Collection Classes Deep Dive - Rocksolid Tour 2013
.Net Collection Classes Deep Dive  - Rocksolid Tour 2013.Net Collection Classes Deep Dive  - Rocksolid Tour 2013
.Net Collection Classes Deep Dive - Rocksolid Tour 2013
 
科特林λ學
科特林λ學科特林λ學
科特林λ學
 
Arrays
ArraysArrays
Arrays
 
eviewsOLSMLE
eviewsOLSMLEeviewsOLSMLE
eviewsOLSMLE
 
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#
 
Scala Back to Basics: Type Classes
Scala Back to Basics: Type ClassesScala Back to Basics: Type Classes
Scala Back to Basics: Type Classes
 
DotNet programming & Practices
DotNet programming & PracticesDotNet programming & Practices
DotNet programming & Practices
 
Introduction to Ruby Programming Language
Introduction to Ruby Programming LanguageIntroduction to Ruby Programming Language
Introduction to Ruby Programming Language
 
My lecture stack_queue_operation
My lecture stack_queue_operationMy lecture stack_queue_operation
My lecture stack_queue_operation
 
Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript core
 

More from ClaudiaNaveda2

Acceleo Best Practices - Obeo.pdf
Acceleo Best Practices - Obeo.pdfAcceleo Best Practices - Obeo.pdf
Acceleo Best Practices - Obeo.pdf
ClaudiaNaveda2
 
Guía Básica de CSS.pptx
Guía Básica de CSS.pptxGuía Básica de CSS.pptx
Guía Básica de CSS.pptx
ClaudiaNaveda2
 
Ejercicio Paises y Provincias.pdf
Ejercicio Paises y Provincias.pdfEjercicio Paises y Provincias.pdf
Ejercicio Paises y Provincias.pdf
ClaudiaNaveda2
 
DiagramaEjercicio1.pdf
DiagramaEjercicio1.pdfDiagramaEjercicio1.pdf
DiagramaEjercicio1.pdf
ClaudiaNaveda2
 
Unidad 2 - Parte 3.ppsx
Unidad 2 - Parte 3.ppsxUnidad 2 - Parte 3.ppsx
Unidad 2 - Parte 3.ppsx
ClaudiaNaveda2
 
ADMINISTRACION 2022- Parte 2.ppt
ADMINISTRACION 2022- Parte 2.pptADMINISTRACION 2022- Parte 2.ppt
ADMINISTRACION 2022- Parte 2.ppt
ClaudiaNaveda2
 
PLANIFICACION vf.ppsx
PLANIFICACION vf.ppsxPLANIFICACION vf.ppsx
PLANIFICACION vf.ppsx
ClaudiaNaveda2
 
SENTENCE STRUCTURE.pdf
SENTENCE STRUCTURE.pdfSENTENCE STRUCTURE.pdf
SENTENCE STRUCTURE.pdf
ClaudiaNaveda2
 
Sentence Structure Text .pdf
Sentence Structure Text .pdfSentence Structure Text .pdf
Sentence Structure Text .pdf
ClaudiaNaveda2
 

More from ClaudiaNaveda2 (9)

Acceleo Best Practices - Obeo.pdf
Acceleo Best Practices - Obeo.pdfAcceleo Best Practices - Obeo.pdf
Acceleo Best Practices - Obeo.pdf
 
Guía Básica de CSS.pptx
Guía Básica de CSS.pptxGuía Básica de CSS.pptx
Guía Básica de CSS.pptx
 
Ejercicio Paises y Provincias.pdf
Ejercicio Paises y Provincias.pdfEjercicio Paises y Provincias.pdf
Ejercicio Paises y Provincias.pdf
 
DiagramaEjercicio1.pdf
DiagramaEjercicio1.pdfDiagramaEjercicio1.pdf
DiagramaEjercicio1.pdf
 
Unidad 2 - Parte 3.ppsx
Unidad 2 - Parte 3.ppsxUnidad 2 - Parte 3.ppsx
Unidad 2 - Parte 3.ppsx
 
ADMINISTRACION 2022- Parte 2.ppt
ADMINISTRACION 2022- Parte 2.pptADMINISTRACION 2022- Parte 2.ppt
ADMINISTRACION 2022- Parte 2.ppt
 
PLANIFICACION vf.ppsx
PLANIFICACION vf.ppsxPLANIFICACION vf.ppsx
PLANIFICACION vf.ppsx
 
SENTENCE STRUCTURE.pdf
SENTENCE STRUCTURE.pdfSENTENCE STRUCTURE.pdf
SENTENCE STRUCTURE.pdf
 
Sentence Structure Text .pdf
Sentence Structure Text .pdfSentence Structure Text .pdf
Sentence Structure Text .pdf
 

Recently uploaded

Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 

Recently uploaded (20)

Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 

OclApunteNavegacion.ppt

  • 1. LANGUAGE SYNTAX: NAVIGATION • Context instance – context Person • Accessing attributes – self.age • Association ends – Navigate to the opposite association end using role names self.employer – Return value is of type Company – Navigation often results into a set of objects – Example context Company self.employees – Return value is of type Set (Person) Person age : int Company employees employer * 1  What does c.employees.employer return?
  • 2. EXAMPLE 1: NAVIGATION (1) • self.persons  {Person p1, Person p2} • self.persons.name  {jack, lisa} • self.persons.age  {30, 22} Person name: String age: int parent children 1 0..* p1:Person name = „jack“ age = 30 Administration 2 * persons p2:Person name = „lisa“ age = 22 v:Administration context Administration:
  • 3. EXAMPLE 1: NAVIGATION (2) • self.persons.children  {p3, p4,p3, p4} // returned as flattened bag • self.persons.children.parent  {p1, p2,p1, p2, ...} • self.persons.car.type  {“audi“} Person name: String age: int parent children 1 0..* p1:Person name = „jack“ age = 30 Administration 2 * persons p2:Person name = „lisa“ age = 22 v:Administration context Administration: p3:Person name = „mick“ age = 1 p4:Person name = „paul“ age = 2 Car type: String * 1 a1:Car type=„audi“ Kinder: Eltern:
  • 4. OCL TYPES (MM VIEW) OCLType TupleType ModelElementType DataType PrimitiveType CollectionType AnyType VoidType String Boolean Integer Real OrderedSetType SequenceType BagType SetType
  • 5. OCL TYPES (A FEATURE MODEL VIEW)
  • 6. OPERATIONS FOR PRIMITIVE/PREDEFINED TYPES  Note that an OrderedSet is not a Set!
  • 7. OPERATIONS FOR PRIMITIVE/PREDEFINED TYPES Simple type Predefined operations Integer *, +, -, /, abs(), … Real *, +, -, /, floor(), … Boolean and, or, xor, not, implies String concat(), size(), substring(), … • Predefined simple types • Integer {Z} • Real {R} • Boolean {true, false} • String {ASCII, Unicode}
  • 8. OPERATIONS FOR OCLANY Operation Explanation of result =(obj2:OclAny):Boolean True, if obj2 and obj reference the same object oclIsTypeOf(type:OclType):Boolean oclIsKindOf(type:OclType): Boolean oclAsType(type:Ocltype): Type The result is obj of type type, or undefined, if the current type of obj is not type or a direct or indirect subtype of it (casting). • OclAny - Supertype of all primitive types • Operations are inherited by all other types. • Operations ofOclAny (extract) • Receiving object is denoted by obj
  • 9. OPERATIONS FOR OCLANY • oclIsKindOf vs. oclIsTypeOf 9 Person Student Professor context Person self.oclIsKindOf(Person) : true self.oclIsTypeOf(Person) : true self.oclIsKindOf(Student) : false self.oclIsTypeOf(Student) : false context Student self.oclIsKindOf(Person) : true self.oclIsTypeOf(Person) : false self.oclIsKindOf(Student) : true self.oclIsTypeOf(Student) : true self.oclIsKindOf(Professor) : false self.oclIsTypeOf(Professor) : false  Can you guess the difference?
  • 10. OCLVOID • OCLVoid includes the null value (and therefore all supertypes of OCLVoid) • Examples null:OCLVoid ada.discount=null : Boolean branch42.address=null : Boolean 1/0=null : Boolean (1/0).oclIsUndefined=true : Boolean 42.oclIsUndefined=false : Boolean Set{’800-275-2273’,’800-694-7466’,null} : Set(String)
  • 11. 3-VALUED LOGIC FOR OCL b | not(b) ------+------- null | null false | true true | false | b2 | b2 b1 or b2 | null false true b1 and b2 | null false true ---------+----------------- ----------+------------------ null | null null true null | null false null b1 false | null false true b1 false | false false false true | true true true true | null false true | b2 | b2 b1 xor b2 | null false true b1 implies b2 | null false true ----------+------------------ --------------+------------------ null | null null null null | null null true b1 false | null false true b1 false | true true true true | null true false true | null false true | b2 | b2 b1 = b2 | null false true b1 <> b2 | null false true ----------+------------------ ---------+------------------ null | true false false null | false true true b1 false | false true false b1 false | true false true true | false false true true | true true false
  • 12. OPERATIONS FOR COLLECTIONS Operation Explanation of result size():Integer Number of elements in coll includes(obj:OclAny):Boolean True, if obj exists in coll isEmpty:Boolean True, if coll contains no elements sum:T Sum of all elements in coll Elements have to be of type Integer or Real • Collection is an abstract supertype for all set types • Specification of the mutual operations • Set, Bag, Sequence, OrderedSet inherit these operations • Caution: Operations with a return value of a set-valued type create a new collection (no side effects) • Syntax: v -> op(…) – Example: {1, 2, 3} -> size()
  • 13. OPERATIONEN FOR SET/BAG Operation Explanation of result union(set2:Set(T)):Set(T) Union of set and set2 intersection(set2:Set(T)):Set(T) Intersection of set and set2 difference(set2:Set(T)):Set() Difference set; elements of set, which do not consist in set2 symmetricDifference(set2:Set(T)): Set(T) Set of all elements, which are either in set or in set2, but do not exist in both sets at the same time • Set and Bag define additional operations • Generally based on theory of set concepts • Operations of Set (extract) • Receiving object is denoted by set Operations of Bag (extract) Operation Explanation of result union(bag2:Bag(T)):Bag(T) Union of bag and bag2 intersection(bag2:Bag(T)): Bag(T) Intersection of bag and bag2 A∩B B A AB BA
  • 14. OPERATIONS FOR ORDEREDSET/SEQUENCE Operation Explanation of result first:T First element of orderedSet last:T Last element of orderedSet at(i:Integer):T Element on index i of orderedSet subOrderedSet(lower:Integer, upper:Integer):OrderedSet(T) Subset of orderedSet, all elements of orderedSet including the element on position lower and the element on position upper insertAt(index:Integer,object:T) :OrderedSet(T) Result is a copy of the orderedSet, including the element object at the position index • OrderedSet and Sequences define additional operations • Allow access or modification through an Index • Operations of OrderedSet (extract) • Receiving object is denoted by orderedSet • Operations of Sequence • Analogous to the operations of OrderedSet 0 1 2 3 … n
  • 15. ITERATOR-BASED OPERATIONS • OCL defines operations for Collections using Iterators – Projection of new Collections out of existing ones – Compact declarative specification instead of imperative algorithms • Predefined Operations – select(exp) : Collection – reject(exp) : Collection – collect(exp) : Collection – forAll(exp) : Boolean – exists(exp) : Boolean – isUnique(exp) : Boolean • iterate(…) – Iterate over all elements of a Collection – Generic operation – Predefined operations are defined with iterate(…) 15
  • 16. SELECT / REJECT • Select and Reject return subsets of collections • Iterate over the complete collection and collect elements • Select • Result: Subset of collection, including elements where booleanExpr is true • Reject • Result: Subset of collection, including elements where booleanExpr is false collection -> select( v : Type | booleanExp(v) ) collection -> select( v | booleanExp(v) ) collection -> select( booleanExp ) collection-> reject(v : Type | booleanExp(v))  Do we need a reject operation?
  • 17. SELECT OPERATION context Company inv: self.employee -> select(e : Employee | e.age>50) -> notEmpty() List persons<Person> = new List(); for ( Iterator<Person> iter = comp.getEmployee(); iter.hasNext() ){ Person p = iter.next(); if ( p.age > 50 ){ persons.add(p); } } Java 5 OCL
  • 18. COLLECT OPERATION • Collect-Operation returns a new collection from an existing one. • Result of collect always Bag<T>.T defines the type of the property to be collected • Example • self.employees -> collect(age) – Return type: Bag(Integer) • Short notation for collect: self.employees.age collection -> collect( v : Type | exp(v) ) collection -> collect( v | exp(v) ) collection -> collect( exp )
  • 19. SEMANTICS OF THE COLLECT OPERATION context Company inv: self.employee ->collect(birthdate) -> size() > 3 List birthdate<Integer> = new List(); for ( Iterator<Person> iter = comp.getEmployee(); iter.hasNext() ){ birthdate.add(iter.next().getBirthdate()); } Java 5 OCL context Company inv: self.employee -> collect(birthdate) -> asSet() OCL Bag (with duplicates) Set (without duplicates)
  • 20. ITERATOR-BASED OPERATIONS • ForAll checks, if all elements of a collection evaluate to true. Example: self.employees -> forAll(age > 18) • Nesting of forAll-Calls (Cartesian Product) • Alternative: Use of multiple iteratores • Exists checks, if at least one element evaluates to true • Self.employees -> exists(e: Employee | e.isManager = true) collection -> forAll( v : Type | booleanExp(v) ) collection -> forAll( v | booleanExp(v) ) collection -> forAll( booleanExp ) context Company inv: self.employee->forAll (e1 | self.employee -> forAll (e2 | e1 <> e2 implies e1.id <> e2.id)) context Company inv: self.employee -> forAll (e1, e2 | e1 <> e2 implies e1.id <> e2.id))
  • 21. ITERATE • Iterate is the generic form of all iterator-based operations • Syntax collection -> iterate( elem : Typ; acc : Typ = <initExp> | exp(elem, acc) ) • Variable elem is a typed Iterator • Variable acc is a typed Accumulator • Gets assigned initial value initExp • exp(elem, acc) is a function to calculate acc • collection -> collect( x : T | x.property ) -- semantically equivalent to: collection -> iterate( x : T; acc : T2 = Bag{} | acc -> including(x.property) )
  • 22. ITERATE • Example – Set{1, 2, 3} -> iterate(i:Integer, a:Integer=0 | a+i) – Result: 6 collection -> iterate(x : T; acc : T2 = value | acc -> u(acc, x) iterate (coll : T, acc : T2 = value){ acc=value; for( Iterator<T> iter = coll.getElements(); iter.hasNext(); ){ T elem = iter.next(); acc = u(elem, acc); } } Java 5 OCL
  • 23. TUPLE TYPES • Tuple types are structured created with the keyword Tuple and by additionally specifying part names and part values. • Tuples and collections are orthogonal Set{Tuple{name:’Ada’,emails:Set{’ada@acm’,’ada@i bm’}},Tuple{name:’Bob’,emails:Sequence{’bob@o mg’,’bob@sun’}}} : Set(Tuple(emails:Collection(String),name:String)) 23
  • 24. NULL VALUES • 0<>null ? • ’’<>null ? • ’null’<>null ? • ’NULL’<>null ? • ’Null’<>null ? 24  All true, null is a value different from all the others
  • 25. COLLECTIONS © AtlanMod - atlanmod-contact@mines-nantes.fr 25
  • 26. COLLECTIONS • Sets are insensible to insertion order and frequency • Ordered Stes are sensible to order, insensible to frequency • Bags are sensible to frequency, insensible to order • Sequence are sensible to both © AtlanMod - atlanmod-contact@mines-nantes.fr 26
  • 27. EXAMPLES OF COLLECTIONS • Set{7,8}=Set{}->including(8)->including(7) Bag{7,8,7}=Bag{8}->including(7)->including(7) Sequence{7,8,7}=Sequence{7,8}->including(7) OrderedSet{7,8}=OrderedSet{7}->including(8)->including(7) Set{7,8}->excluding(8)=Set{7} Bag{7,8,7}->excluding(7)=Bag{8} Sequence{7,8,7}->excluding(7)=Sequence{8} OrderedSet{9,6,7,8,6,7}->excluding(6)=OrderedSet{9,7,8} © AtlanMod - atlanmod-contact@mines-nantes.fr 27
  • 28. COLLECTION CASTING • Some ambiguos conversions • Sequence{8,7,7,8}->asSet() = Set{7,8} : • Sequence{8,7,7,8}->asBag() = Bag{7,7,8,8} • Set{8,7,7,8}->asSequence() ? Sequence{7,8} ?Sequence{8,7} 28  Implementator’s decision!!  Also others like :  Set{7,8,9}->any(true)
  • 29. COLLECTION EQUALITY • Set{7,8} = Set{8,7,7} • Set{7,8} = Bag{7,8} • OrderedSet{8,9} = Sequence{8,9} • OrderedSet{7,8,8} = OrderedSet{7,8,7} • OrderedSet{7,9,8} = OrderedSet{9,7,8} © AtlanMod - atlanmod-contact@mines-nantes.fr 29