SlideShare a Scribd company logo
Employing the Object Constraint Language
in Model-Based Engineering
Martin Gogolla
University of Bremen
Database Systems Group
Outline
●
Motivation: About modeling
●
Modeling with UML and OCL
●
Validation and verification of structure
●
Validation and verification of behavior
Why do engineers build models?
- To understand
... problems and solutions
Models as "Means for Knowledge Acquisition"
- To communicate
... understanding and design intent
Models as "Means for Knowledge Transfer"
- To predict
... the interesting characteristics of system under study
Models as "Surrogates"
- To specify
... the implementation of the system
Models as "Blueprints"
Building models is done by selecting statements through
abstraction, i.e., reduction of information preserving
properties relative to a given set of concerns
[From: Bran Selic, UML2 Tutorial @ MoDELS 2012]
System under study Abstraction Statements (Models)
A model describes a Labelled Transition System
Outline
●
Motivation: About modeling
●
Modeling with UML and OCL
●
Validation and verification of structure
●
Validation and verification of behavior
Ecmfa2013
Model analysis
●
Aim of model analysis: Check model for relevant and interesting
properties; detect deficiencies on the modeling level before
implementation
●
Example properties
– Is the set of states and transitions not empty?
Which properties do the states have?
– Which transition sequences are possible?
– Are the transitions deterministic?
Are there states with no outgoing transition?
– ...
●
General model properties: Consistency, Independence (Minimality),
Detection of consequences, Exploration of reachability, ...
(Textual) Modeling with UML and OCL within USE
(UML-based Specification Environment)
●
Class diagrams (classes, associations, generalization, abstract
classes, association clases, aggregation, composition, ...)
●
Protocol State Machines (states and guarded transitions)
●
Support for full OCL with all collection kinds (sets, bags, sequences,
ordered sets) and operations (forAll, select, collect, iterate, closure, ...)
●
Central assurance technique: Expressing scenarios (test cases);
UML object and sequence diagrams
●
Employing OCL for ad-hoc queries, class invariants, operation pre-
and postconditions, operation definitions (for side-effect free
operations), state invariants, transition pre- and postconditions
●
Employing SOIL (Simple Ocl-like Imperative Language) for
implementing operations manipulating the system state
●
Validation: Are we building the right product?
Verification: Are we building the product right?
Ecmfa2013
Outline
●
Motivation: About modeling
●
Modeling with UML and OCL
●
Validation and verification of structure
●
Validation and verification of behavior
Model understanding and analysis with positive examples
●
Search for scenarios satisfying all constraints
●
Prove consistency of structural model
●
Provide valid object diagrams with meaningful objects and values to
stakeholders not interested in technical details
●
Systematically construct object diagrams in order to span up a
particular search space consisting of a sequence of object diagrams
●
Automatically construct object diagrams with the so-called
model validator which realizes a transformation from UML and OCL
into relational logic implemented in Alloy resp. Kodkod
Ecmfa2013
Ecmfa2013
Ecmfa2013
Ecmfa2013
All constraints valid: Consistency of invariants & inherent constraints
One constraint fails
context Person inv asymmetricFriendship:
inviter->intersection(invitee)->isEmpty
context Person inv listMembersMustBeFriends:
friends()->includesAll(ownedList->collect(l|l.member))
context Access inv accessOnlyToFriends:
accessed.poster.friends()->includesAll(accessor.pAccessor())
context Commenting inv commentOnlyByFriends:
commented.poster.friends()->includes(commenter)
context Commenting inv commentOnlyIfUndenied:
commented.denied()->excludes(commenter)
Person::friends():Set(Person)=
invitee->union(inviter)->excluding(self)
Person::pAccessor():Set(Person)=Set{self}
List::pAccessor():Set(Person)=member
Post::denied():Set(Person)=
access->select(deny=true).accessor.pAccessor()->asSet()
Model analysis with negative examples
●
Positive and negative scenarios (test cases) desireable
●
Scenarios may also violate constraints
●
Violating scenarios uncover interesting properties
Independence of invariants
●
Configure the invariants before calling the search procedure by
negating or disabling them
●
Explore invariant indepence by negating exactly one invariant
●
If successful, the found object diagram proves independence
● ∃ ObjDia ( INV1
ᴧ ¬ INV2
ᴧ INV3
)
↔ ∃ ObjDia ( INV1
ᴧ INV3
¬ᴧ INV2
)
↔ ∃ ObjDia ¬ ¬ ( INV1
ᴧ INV3
¬ᴧ INV2
)
↔ ¬ ∀ ObjDia ( ¬ ( INV1
ᴧ INV3
) ˅ INV2
)
↔ ¬ ∀ ObjDia ( INV1
ᴧ INV3
⇒ INV2
)
● INV2
independentOf ( INV1
ᴧ INV3
)
●
Similar technique can be employed for checking consequences
Outline
●
Motivation: About modeling
●
Modeling with UML and OCL
●
Validation and verification of structure
●
Validation and verification of behavior
Modeling Behavior with SOIL and Statecharts
●
Employ OCL pre- and postconditions for operations
●
Employ SOIL statements for implementing operations
manipulating the system state
●
Employ UML statecharts (UML protocol state machines)
for specifying complete object life cycles (in extension to the
OCL pre- and postconditions which cover single state transitions with
one pre and one post state)
●
Employ UML sequence diagrams for capturing execution traces
with object lifelines and exchanged messages
Life cycle restriction with state charts:
'accept' and 'decline' not always possible
class Person < Accessor
operations
invite(invitee:Person)
begin SOIL
[prescriptive]
insert (self,invitee) into Pendship;
invitee.invited(self);
end
pre inviteeNotSelf: invitee<>self OCL
[descriptive]
pre inviteeNotFriend: friends()->excludes(invitee)
pre inviteeNotPending: pends()->excludes(invitee)
post pInvited: self.pInvitee->includes(invitee)
accept(inviter:Person)
begin
inviter.accepted(self);
delete (inviter,self) from Pendship;
insert (inviter,self) into Friendship;
end
pre pInvited: inviter.pInvitee->includes(self)
post pendingCanceled: inviter.pInvitee->excludes(self)
post invited: inviter.invitee->includes(self)
decline(inviter:Person) ...
invited(inviter:Person) ...
accepted(invitee:Person) ...
declined(invitee:Person) ...
end
Ecmfa2013
Ecmfa2013
Ecmfa2013
Ecmfa2013
Ecmfa2013
Ecmfa2013
Result of scenario construction
●
Structural model: Class diagram and invariants
●
Behavioral model: Operation pre- and postconditions, SOIL operation
realization, and statecharts including transition pre- and
postconditions and state invariants
●
All operations touched at least once in the scenario
●
Invariants, operation pre- and postconditions, and transition pre- and
post conditions are all valid
●
Structural and behavioral model are consistent
Summary
●
Software development concentrating on models as first class citizens
●
Successfully applied approach in larger German project:
XGenerator @ Deutschland online
●
UML (Class and Statechart diagrams) in combination with OCL (not
mentioned yet the darker side of the force, namely class diagram
features like subsets, redefines, union, association inheritance and
association class inheritance)
●
SOIL (Simple Ocl-like Imperative Language) for operation
implementation together model unit tests (Object and Sequence
diagrams)
●
Employ model validator for searching object diagram spaces
●
Validation and verification
●
Aim of modeling: Obtain trustworthy models
Perspectives
●
Support for model transformation: From descriptive models to
prescriptive models, from platform-indepedent models to platform-
dependent ones, ...
●
Technical extension in USE
- statecharts features, e.g. adding change events and nested states
- sequence diagram, e.g. states and object diagram on lifelines
●
Filmstriping models, i.e. simulating system dynamics by encoding
filmstrips (state sequences and operation calls) into a single state
●
Temporal logic for dynamic properties!
Deontic logic for obligations and permissions?
●
Monitoring running applications (JVM, CRL, ...) with models
●
THANKS: to Mark Richters, Jörn Bohling, Fabian Büttner,
Mirco Kuhlmann and Lars Hamann for their work on USE!
Apologies for this long presentation. I did not find
the time to prepare a short smart one. [B. Pascal]
Thanks for your attention!
Relevant Properties
●
Consistency: Are the model inherent constraints (e.g., multiplicities,
agggregation, composition) and class invariants consistent? Is there
at least one object diagram? Empty populations? Finite populations?
Classes? Associations? Consistency also for other constraints, e.g.
invariants and operation pre- and postconditions?
●
Independence: Are the class invariants independent? Is there an
invariant which is implied by the other invariants? Are the invariants
implied by the operation pre- and postconditions?
●
Consequences: Is a newly stated invariant a consequence of the
stated ones? Must operationA always be followed by operationB?
●
Reachability: Is a given object diagram reachable from another object
diagram through a sequence of operation calls? Which operation calls
lead from a start object diagram to an end object diagram? Are there
operation call sequences leading to dead end object diagrams?
●
Many further properties worth to be investigated!
Example property: Agggregation and composition
context Person inv cannotBeMemberOfFriendsList:
ownedList.member.ownedList.member->excludes(self)
Object diagram
violating diamonds
and constraint
Pendship = Pending Friendship
Actual model a bit more complicated: internal operations needed
'on the other side' of the invitation: 'invited', 'accepted', and 'declined'
sys.String2ObjDia(
Sequence{
Tuple{PERSON:'ada',
INVITEES:Sequence{'bob','cyd'},
POSTS:Sequence{'ada_birthday','ada_marriage'},
COMMENTS:Sequence{'bob_promotion','well
done'},
DENIES:Sequence{'ada_birthday','cyd'}},
Tuple{PERSON:'bob',
INVITEES:Sequence{'cyd'},
POSTS:Sequence{'bob_birthday','bob_promotion'},
COMMENTS:Sequence{'ada_birthday','congrats',
'cyd_birthday','congrats'},
DENIES:Sequence{}},
Tuple{PERSON:'cyd',
INVITEES:Sequence{},
POSTS:Sequence{'cyd_birthday'},
COMMENTS:Sequence{'bob_promotion','cheers'},
DENIES:Sequence{'cyd_birthday','ada'}}})
System::String2ObjDia(s:
Sequence(Tuple(PERSON:String,
INVITEES:Sequence(String),
POSTS:Sequence(String),
COMMENTS:Sequence(String),
DENIES:Sequence(String))) )
Ecmfa2013
Ecmfa2013
Ecmfa2013
String2ObjDia(s:Seq(Tuple(PERSON:String, parameters &
class/assoc
INVITEES:Sequence(String), SOIL
features
POSTS:Sequence(String),
COMMENTS:Sequence(String),
DENIES:Sequence(String))))
begin
declare ps:Person, po:Post, po_str:String, co_str:String,
co:Commenting, ps_str:String, ac:Access;
for x in s->collectNested(e|e.PERSON) do
ps:=new Person(x); end;
for x in s->collectNested(e|e.PERSON) do
for y in s->any(e|e.PERSON=x).INVITEES do
insert (Person.byUseId(x),Person.byUseId(y)) into Friendship; end;
end;
for x in s->collectNested(e|e.PERSON) do
for y in s->any(e|e.PERSON=x).POSTS do
po:=new Post(y); insert (Person.byUseId(x),Post.byUseId(y)) into
Posting;
end; end;
for x in s->collectNested(e|e.PERSON) do
for y in Set{0..(s->any(e|e.PERSON=x).COMMENTS->size() div 2)-1} do
po_str:=s->any(e|e.PERSON=x).COMMENTS->at(y*2+1);
co_str:=s->any(e|e.PERSON=x).COMMENTS->at(y*2+2);
co:=new Commenting between (Person.byUseId(x),Post.byUseId(po_str));
co.comment:=co_str; end; end;
for x in s->collectNested(e|e.PERSON) do
for y in Set{0..(s->any(e|e.PERSON=x).DENIES->size() div 2)-1} do
po_str:=s->any(e|e.PERSON=x).DENIES->at(y*2+1);
ps_str:=s->any(e|e.PERSON=x).DENIES->at(y*2+2);
ac:=new Access between(Post.byUseId(po_str),Person.byUseId(ps_str));
ac.deny:=true; end; end;
procedure societyComplete(numPerson:Integer,
numFriendship:Integer,
numList:Integer, numMember:Integer, numPost:Integer,
numComment:Integer, numDeny:Integer)
var persons:Sequence(Person), p1:Person, p2:Person,
lists:Sequence(List), l:List, po:Post, posts:Sequence(Post),
acc:Accessor, commentings:Sequence(Commenting),
accesses:Sequence(Access)
begin
persons:=CreateN(Person,[numPerson])
for i:Integer in [Sequence{1..numFriendship}]
begin p1:=Try([persons]) p2:=Try([persons])
if [p1.invitee->excludes(p2)] then
begin Insert(Friendship,[p1],[p2]) end
end
lists:=CreateN(List,[numList])
for i:Integer in [Sequence{1..numList}]
.. Insert(ListOwnership,[p1],[lists->at(i)]) ..
..ListMembership..Post..Posting..
for i:Integer in [Sequence{1..numComment}]
.. Create(Commenting,[p1],[po]) ..
..
for i:Integer in [Sequence{1..commentings->size}]
.. [commentings->at(i)].comment:=[''] ..
for i:Integer in [Sequence{1..numDeny}]
.. acc:=Try([persons->union(lists)]) ..
..
end
Ecmfa2013
Ecmfa2013
From B. Selic: MODELS 2012 Tutorial
Ecmfa2013
context Person inv noSelfInvitation: OCL collection operations
invitee->excludes(self)
context p1,p2:Person inv symmetricFriends:
p1.friends()->includes(p2)=p2.friends()->includes(p1)
context Person inv listMembersMustBeFriends:
friends()->includesAll(ownedList->collect(l|l.member))
context Person inv asymmetricFriendship:
inviter->intersection(invitee)->isEmpty()
context Access inv accessOnlyToFriends: ...
context Commenting inv commentOnlyByFriends: ...
context Commenting inv commentOnlyIfUndenied:
commented.denied()->excludes(commenter)
Person::friends():Set(Person)=
invitee->union(inviter)->excluding(self)
Person::pAccessor():Set(Person)=Set{self}
List::pAccessor():Set(Person)=member
Post::denied():Set(Person)=
access->select(deny=true).accessor.pAccessor()->asSet()

More Related Content

PPT
Object oriented analysis & Design- Overview
PPTX
fUML-Driven Design and Performance Analysis of Software Agents for Wireless S...
PPTX
Structured Vs, Object Oriented Analysis and Design
PPSX
MDE in Practice
PPT
02 uml
PDF
CS8592-OOAD Lecture Notes Unit-3
PDF
CS8592-OOAD Question Bank
PDF
Seng 123 8-ooad
Object oriented analysis & Design- Overview
fUML-Driven Design and Performance Analysis of Software Agents for Wireless S...
Structured Vs, Object Oriented Analysis and Design
MDE in Practice
02 uml
CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Question Bank
Seng 123 8-ooad

What's hot (12)

PDF
[2016/2017] Architectural languages
PDF
Round - Trip Software Engineering using UML: From Architecture to Design and...
PDF
Case stydy cs701
PPT
UML (Hemant rajak)
PPTX
PPT
Object Oriented Methodology in Java (Lecture-1)
PPSX
UML and Case study
PDF
Arch06 1
PPTX
Unit 1- OOAD ppt
PPTX
Model-Driven Testing with UML 2.0
PDF
Advanced Modeling of Industrial Optimization Problems
PDF
Time Series Estimation of Gas Furnace Data in IMPL and CPLEX Industrial Model...
[2016/2017] Architectural languages
Round - Trip Software Engineering using UML: From Architecture to Design and...
Case stydy cs701
UML (Hemant rajak)
Object Oriented Methodology in Java (Lecture-1)
UML and Case study
Arch06 1
Unit 1- OOAD ppt
Model-Driven Testing with UML 2.0
Advanced Modeling of Industrial Optimization Problems
Time Series Estimation of Gas Furnace Data in IMPL and CPLEX Industrial Model...
Ad

Viewers also liked (18)

PPT
Pap2 3
DOCX
Tarea 01 - Nuevos Ambientes de Aprendizaje
PDF
Tutorial de-busquedas-con-google
PDF
DNV Satish
PPT
Het Nieuwe Werken Sra (Nr)
PPT
Data handling
PDF
Física General
DOCX
Deber de informatica dayane caiza y danny cushpa
PDF
Portfolio_Pankaj Sharma
PDF
Countus tulp over 2 jaar te koop
ODP
Gu a tur_stica_alejandro (1)
PDF
Tap2013
PDF
Cómo ayudar a su hijo a aprender ciencias
PPTX
An Dewaele, Veranderingsmanagement: do's and dont's voor archiefteams
PDF
lecturas de primer ciclo
PPT
Literatura en el Barroco ( S.XVII)
PPTX
Parodoncijum
PPT
Inteligencia Verbal Lingüistica
Pap2 3
Tarea 01 - Nuevos Ambientes de Aprendizaje
Tutorial de-busquedas-con-google
DNV Satish
Het Nieuwe Werken Sra (Nr)
Data handling
Física General
Deber de informatica dayane caiza y danny cushpa
Portfolio_Pankaj Sharma
Countus tulp over 2 jaar te koop
Gu a tur_stica_alejandro (1)
Tap2013
Cómo ayudar a su hijo a aprender ciencias
An Dewaele, Veranderingsmanagement: do's and dont's voor archiefteams
lecturas de primer ciclo
Literatura en el Barroco ( S.XVII)
Parodoncijum
Inteligencia Verbal Lingüistica
Ad

Similar to Ecmfa2013 (20)

PPTX
The secret life of rules in Software Engineering
PDF
On the verification of UML/OCL class diagrams using constraint programming
PPT
IntroductionToUML.ppt
PPTX
lecture 2.pptx
PDF
Comparison of the Formal Specification Languages Based Upon Various Parameters
PPT
Visual Modelling and the Unified Modeling Language.ppt
PDF
Towards Domain Refinement for UML/OCL Bounded Verification
PDF
5-Object Oriented Analysis (Object Oriented Software Engineering - BNU Spring...
PPT
Unified Modeling Language (UML)
PDF
PDF
SE_Lec 09_ UML Behaviour Diagrams
PDF
Datalog+-Track Introduction & Reasoning on UML Class Diagrams via Datalog+-
PPT
Object oriented programming in C++ programming language
PPT
Object oriented programming language in software engineering
PPT
Introduction to software engineering in data science.ppt
PPT
An Evolution of UML projects.and also what is project
PPTX
Unit4 desiging classes
PPTX
Unit4 desiging classes
PDF
Beyond design principles and patterns (muCon 2019 edition)
PPTX
Software Engineering and Project Management - Introduction, Modeling Concepts...
The secret life of rules in Software Engineering
On the verification of UML/OCL class diagrams using constraint programming
IntroductionToUML.ppt
lecture 2.pptx
Comparison of the Formal Specification Languages Based Upon Various Parameters
Visual Modelling and the Unified Modeling Language.ppt
Towards Domain Refinement for UML/OCL Bounded Verification
5-Object Oriented Analysis (Object Oriented Software Engineering - BNU Spring...
Unified Modeling Language (UML)
SE_Lec 09_ UML Behaviour Diagrams
Datalog+-Track Introduction & Reasoning on UML Class Diagrams via Datalog+-
Object oriented programming in C++ programming language
Object oriented programming language in software engineering
Introduction to software engineering in data science.ppt
An Evolution of UML projects.and also what is project
Unit4 desiging classes
Unit4 desiging classes
Beyond design principles and patterns (muCon 2019 edition)
Software Engineering and Project Management - Introduction, Modeling Concepts...

Recently uploaded (20)

PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
Machine Learning_overview_presentation.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
A Presentation on Artificial Intelligence
PPTX
MYSQL Presentation for SQL database connectivity
PPT
Teaching material agriculture food technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Spectroscopy.pptx food analysis technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
A comparative analysis of optical character recognition models for extracting...
Machine Learning_overview_presentation.pptx
Unlocking AI with Model Context Protocol (MCP)
“AI and Expert System Decision Support & Business Intelligence Systems”
Advanced methodologies resolving dimensionality complications for autism neur...
Chapter 3 Spatial Domain Image Processing.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
NewMind AI Weekly Chronicles - August'25-Week II
A Presentation on Artificial Intelligence
MYSQL Presentation for SQL database connectivity
Teaching material agriculture food technology
MIND Revenue Release Quarter 2 2025 Press Release
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Electronic commerce courselecture one. Pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation_ Review paper, used for researhc scholars
Spectroscopy.pptx food analysis technology
Building Integrated photovoltaic BIPV_UPV.pdf

Ecmfa2013

  • 1. Employing the Object Constraint Language in Model-Based Engineering Martin Gogolla University of Bremen Database Systems Group
  • 2. Outline ● Motivation: About modeling ● Modeling with UML and OCL ● Validation and verification of structure ● Validation and verification of behavior
  • 3. Why do engineers build models? - To understand ... problems and solutions Models as "Means for Knowledge Acquisition" - To communicate ... understanding and design intent Models as "Means for Knowledge Transfer" - To predict ... the interesting characteristics of system under study Models as "Surrogates" - To specify ... the implementation of the system Models as "Blueprints" Building models is done by selecting statements through abstraction, i.e., reduction of information preserving properties relative to a given set of concerns [From: Bran Selic, UML2 Tutorial @ MoDELS 2012]
  • 4. System under study Abstraction Statements (Models)
  • 5. A model describes a Labelled Transition System
  • 6. Outline ● Motivation: About modeling ● Modeling with UML and OCL ● Validation and verification of structure ● Validation and verification of behavior
  • 8. Model analysis ● Aim of model analysis: Check model for relevant and interesting properties; detect deficiencies on the modeling level before implementation ● Example properties – Is the set of states and transitions not empty? Which properties do the states have? – Which transition sequences are possible? – Are the transitions deterministic? Are there states with no outgoing transition? – ... ● General model properties: Consistency, Independence (Minimality), Detection of consequences, Exploration of reachability, ...
  • 9. (Textual) Modeling with UML and OCL within USE (UML-based Specification Environment) ● Class diagrams (classes, associations, generalization, abstract classes, association clases, aggregation, composition, ...) ● Protocol State Machines (states and guarded transitions) ● Support for full OCL with all collection kinds (sets, bags, sequences, ordered sets) and operations (forAll, select, collect, iterate, closure, ...) ● Central assurance technique: Expressing scenarios (test cases); UML object and sequence diagrams ● Employing OCL for ad-hoc queries, class invariants, operation pre- and postconditions, operation definitions (for side-effect free operations), state invariants, transition pre- and postconditions ● Employing SOIL (Simple Ocl-like Imperative Language) for implementing operations manipulating the system state ● Validation: Are we building the right product? Verification: Are we building the product right?
  • 11. Outline ● Motivation: About modeling ● Modeling with UML and OCL ● Validation and verification of structure ● Validation and verification of behavior
  • 12. Model understanding and analysis with positive examples ● Search for scenarios satisfying all constraints ● Prove consistency of structural model ● Provide valid object diagrams with meaningful objects and values to stakeholders not interested in technical details ● Systematically construct object diagrams in order to span up a particular search space consisting of a sequence of object diagrams ● Automatically construct object diagrams with the so-called model validator which realizes a transformation from UML and OCL into relational logic implemented in Alloy resp. Kodkod
  • 17. All constraints valid: Consistency of invariants & inherent constraints
  • 19. context Person inv asymmetricFriendship: inviter->intersection(invitee)->isEmpty context Person inv listMembersMustBeFriends: friends()->includesAll(ownedList->collect(l|l.member)) context Access inv accessOnlyToFriends: accessed.poster.friends()->includesAll(accessor.pAccessor()) context Commenting inv commentOnlyByFriends: commented.poster.friends()->includes(commenter) context Commenting inv commentOnlyIfUndenied: commented.denied()->excludes(commenter) Person::friends():Set(Person)= invitee->union(inviter)->excluding(self) Person::pAccessor():Set(Person)=Set{self} List::pAccessor():Set(Person)=member Post::denied():Set(Person)= access->select(deny=true).accessor.pAccessor()->asSet()
  • 20. Model analysis with negative examples ● Positive and negative scenarios (test cases) desireable ● Scenarios may also violate constraints ● Violating scenarios uncover interesting properties
  • 21. Independence of invariants ● Configure the invariants before calling the search procedure by negating or disabling them ● Explore invariant indepence by negating exactly one invariant ● If successful, the found object diagram proves independence ● ∃ ObjDia ( INV1 ᴧ ¬ INV2 ᴧ INV3 ) ↔ ∃ ObjDia ( INV1 ᴧ INV3 ¬ᴧ INV2 ) ↔ ∃ ObjDia ¬ ¬ ( INV1 ᴧ INV3 ¬ᴧ INV2 ) ↔ ¬ ∀ ObjDia ( ¬ ( INV1 ᴧ INV3 ) ˅ INV2 ) ↔ ¬ ∀ ObjDia ( INV1 ᴧ INV3 ⇒ INV2 ) ● INV2 independentOf ( INV1 ᴧ INV3 ) ● Similar technique can be employed for checking consequences
  • 22. Outline ● Motivation: About modeling ● Modeling with UML and OCL ● Validation and verification of structure ● Validation and verification of behavior
  • 23. Modeling Behavior with SOIL and Statecharts ● Employ OCL pre- and postconditions for operations ● Employ SOIL statements for implementing operations manipulating the system state ● Employ UML statecharts (UML protocol state machines) for specifying complete object life cycles (in extension to the OCL pre- and postconditions which cover single state transitions with one pre and one post state) ● Employ UML sequence diagrams for capturing execution traces with object lifelines and exchanged messages
  • 24. Life cycle restriction with state charts: 'accept' and 'decline' not always possible
  • 25. class Person < Accessor operations invite(invitee:Person) begin SOIL [prescriptive] insert (self,invitee) into Pendship; invitee.invited(self); end pre inviteeNotSelf: invitee<>self OCL [descriptive] pre inviteeNotFriend: friends()->excludes(invitee) pre inviteeNotPending: pends()->excludes(invitee) post pInvited: self.pInvitee->includes(invitee) accept(inviter:Person) begin inviter.accepted(self); delete (inviter,self) from Pendship; insert (inviter,self) into Friendship; end pre pInvited: inviter.pInvitee->includes(self) post pendingCanceled: inviter.pInvitee->excludes(self) post invited: inviter.invitee->includes(self) decline(inviter:Person) ... invited(inviter:Person) ... accepted(invitee:Person) ... declined(invitee:Person) ... end
  • 32. Result of scenario construction ● Structural model: Class diagram and invariants ● Behavioral model: Operation pre- and postconditions, SOIL operation realization, and statecharts including transition pre- and postconditions and state invariants ● All operations touched at least once in the scenario ● Invariants, operation pre- and postconditions, and transition pre- and post conditions are all valid ● Structural and behavioral model are consistent
  • 33. Summary ● Software development concentrating on models as first class citizens ● Successfully applied approach in larger German project: XGenerator @ Deutschland online ● UML (Class and Statechart diagrams) in combination with OCL (not mentioned yet the darker side of the force, namely class diagram features like subsets, redefines, union, association inheritance and association class inheritance) ● SOIL (Simple Ocl-like Imperative Language) for operation implementation together model unit tests (Object and Sequence diagrams) ● Employ model validator for searching object diagram spaces ● Validation and verification ● Aim of modeling: Obtain trustworthy models
  • 34. Perspectives ● Support for model transformation: From descriptive models to prescriptive models, from platform-indepedent models to platform- dependent ones, ... ● Technical extension in USE - statecharts features, e.g. adding change events and nested states - sequence diagram, e.g. states and object diagram on lifelines ● Filmstriping models, i.e. simulating system dynamics by encoding filmstrips (state sequences and operation calls) into a single state ● Temporal logic for dynamic properties! Deontic logic for obligations and permissions? ● Monitoring running applications (JVM, CRL, ...) with models ● THANKS: to Mark Richters, Jörn Bohling, Fabian Büttner, Mirco Kuhlmann and Lars Hamann for their work on USE!
  • 35. Apologies for this long presentation. I did not find the time to prepare a short smart one. [B. Pascal] Thanks for your attention!
  • 36. Relevant Properties ● Consistency: Are the model inherent constraints (e.g., multiplicities, agggregation, composition) and class invariants consistent? Is there at least one object diagram? Empty populations? Finite populations? Classes? Associations? Consistency also for other constraints, e.g. invariants and operation pre- and postconditions? ● Independence: Are the class invariants independent? Is there an invariant which is implied by the other invariants? Are the invariants implied by the operation pre- and postconditions? ● Consequences: Is a newly stated invariant a consequence of the stated ones? Must operationA always be followed by operationB? ● Reachability: Is a given object diagram reachable from another object diagram through a sequence of operation calls? Which operation calls lead from a start object diagram to an end object diagram? Are there operation call sequences leading to dead end object diagrams? ● Many further properties worth to be investigated!
  • 37. Example property: Agggregation and composition context Person inv cannotBeMemberOfFriendsList: ownedList.member.ownedList.member->excludes(self) Object diagram violating diamonds and constraint
  • 38. Pendship = Pending Friendship
  • 39. Actual model a bit more complicated: internal operations needed 'on the other side' of the invitation: 'invited', 'accepted', and 'declined'
  • 44. String2ObjDia(s:Seq(Tuple(PERSON:String, parameters & class/assoc INVITEES:Sequence(String), SOIL features POSTS:Sequence(String), COMMENTS:Sequence(String), DENIES:Sequence(String)))) begin declare ps:Person, po:Post, po_str:String, co_str:String, co:Commenting, ps_str:String, ac:Access; for x in s->collectNested(e|e.PERSON) do ps:=new Person(x); end; for x in s->collectNested(e|e.PERSON) do for y in s->any(e|e.PERSON=x).INVITEES do insert (Person.byUseId(x),Person.byUseId(y)) into Friendship; end; end; for x in s->collectNested(e|e.PERSON) do for y in s->any(e|e.PERSON=x).POSTS do po:=new Post(y); insert (Person.byUseId(x),Post.byUseId(y)) into Posting; end; end; for x in s->collectNested(e|e.PERSON) do for y in Set{0..(s->any(e|e.PERSON=x).COMMENTS->size() div 2)-1} do po_str:=s->any(e|e.PERSON=x).COMMENTS->at(y*2+1); co_str:=s->any(e|e.PERSON=x).COMMENTS->at(y*2+2); co:=new Commenting between (Person.byUseId(x),Post.byUseId(po_str)); co.comment:=co_str; end; end; for x in s->collectNested(e|e.PERSON) do for y in Set{0..(s->any(e|e.PERSON=x).DENIES->size() div 2)-1} do po_str:=s->any(e|e.PERSON=x).DENIES->at(y*2+1); ps_str:=s->any(e|e.PERSON=x).DENIES->at(y*2+2); ac:=new Access between(Post.byUseId(po_str),Person.byUseId(ps_str)); ac.deny:=true; end; end;
  • 45. procedure societyComplete(numPerson:Integer, numFriendship:Integer, numList:Integer, numMember:Integer, numPost:Integer, numComment:Integer, numDeny:Integer) var persons:Sequence(Person), p1:Person, p2:Person, lists:Sequence(List), l:List, po:Post, posts:Sequence(Post), acc:Accessor, commentings:Sequence(Commenting), accesses:Sequence(Access) begin persons:=CreateN(Person,[numPerson]) for i:Integer in [Sequence{1..numFriendship}] begin p1:=Try([persons]) p2:=Try([persons]) if [p1.invitee->excludes(p2)] then begin Insert(Friendship,[p1],[p2]) end end lists:=CreateN(List,[numList]) for i:Integer in [Sequence{1..numList}] .. Insert(ListOwnership,[p1],[lists->at(i)]) .. ..ListMembership..Post..Posting.. for i:Integer in [Sequence{1..numComment}] .. Create(Commenting,[p1],[po]) .. .. for i:Integer in [Sequence{1..commentings->size}] .. [commentings->at(i)].comment:=[''] .. for i:Integer in [Sequence{1..numDeny}] .. acc:=Try([persons->union(lists)]) .. .. end
  • 48. From B. Selic: MODELS 2012 Tutorial
  • 50. context Person inv noSelfInvitation: OCL collection operations invitee->excludes(self) context p1,p2:Person inv symmetricFriends: p1.friends()->includes(p2)=p2.friends()->includes(p1) context Person inv listMembersMustBeFriends: friends()->includesAll(ownedList->collect(l|l.member)) context Person inv asymmetricFriendship: inviter->intersection(invitee)->isEmpty() context Access inv accessOnlyToFriends: ... context Commenting inv commentOnlyByFriends: ... context Commenting inv commentOnlyIfUndenied: commented.denied()->excludes(commenter) Person::friends():Set(Person)= invitee->union(inviter)->excluding(self) Person::pAccessor():Set(Person)=Set{self} List::pAccessor():Set(Person)=member Post::denied():Set(Person)= access->select(deny=true).accessor.pAccessor()->asSet()