The role of OCL in the Model Driven Architecture - PowerPoint PPT Presentation

1 / 57
About This Presentation
Title:

The role of OCL in the Model Driven Architecture

Description:

Platform Independent Model. PSM JSP. PSM SQL. PSM EJB. Klasse ... Declarative and platform independent. Precision. Unambiguous, formal (?) Klasse. Objecten ... – PowerPoint PPT presentation

Number of Views:92
Avg rating:3.0/5.0
Slides: 58
Provided by: joswa
Category:

less

Transcript and Presenter's Notes

Title: The role of OCL in the Model Driven Architecture


1
The role of OCL in theModel Driven Architecture
  • Jos Warmer
  • Klasse Objecten
  • J.Warmer_at_klasse.nl
  • http//www.klasse.nl

2
Part 1
  • The role of modeling in software development.

3
Modeling Maturity Levels
  • MML 0 No specification
  • MML 1 Textual Specification
  • MML 2 Text with Models
  • MML 3 Models with Text
  • MML 4 Precise Models
  • MML 5 Models only

4
MML 0 No Specification
?
My software
  • Specification of software is kept in the heads of
    the developers.

5
MML 1 Textual
?
  • Specification of software is written down in one
    or more natural language documents.

6
MML 2 Text with Diagrams
? ?
  • Specification of software in one or more natural
    language documents
  • plus several high-level diagrams to explain the
    overall architecture.


7
MML 3 Models with Text
? ? ?
  • Specification of software is written down in one
    or more models.
  • Additional natural language text is used to
    explain the background and motivation of the
    models.


8
MML 4 Precise Models
? ? ? ?
  • Specification of software is written down in one
    or more models.
  • Natural language text is used to explain the
    background and motivation of the models.
  • The models are precise enough to have a direct
    link with the actual code.
  • This is what the OMG calls MDA or Model Driven
    architecture.

9
MML 5 Models Only
? ? ? ? ?
  • The models are precise and detailed enough to
    allow complete code-generation.
  • The code is invisible (as assembler is today).
  • Modeling language ? High level programming
    language.
  • This is future technology (?).

10
UML in the MMLs
  • MML 0 No use of UML
  • MML 1 No use of UML
  • MML 2 Moderate use of UML
  • MML 3 Extensive use of UML
  • MML 4 Extensive use of UML with OCL
  • MML 5 ???

11
MDA and MML
? ? ? ?
  • OMGs Model Driven Architecture is designed for
    MML level 4
  • Ultimate goal is level 5
  • UML and OCL play an important role

12
MDA Overview
  • Automatic transformation from platform
    independent model (PIM) to platform specific
    models (PSM).
  • PIM usually written in UML.
  • PSM can be diverse
  • Java, J2EE, SQL, C, .NET, COBOL, C, CORBA,
    XML, etc. etc.
  • Bridges between PSMs generated as well.

13
MDA Example
14
Experience in moving to MDA
  • Companies moving from MML 3 to MML 4 (MDA)
    realize the need for OCL and are using it.
  • Tools vendors developing tools for MDA realize
    the same and add support for OCL (e.g. ArcStyler,
    OptimalJ).

15
Part 2 OCL
16
Object Constraint Language
  • OCL is about objects
  • OCL is a language
  • OCL is not just about constraints
  • OCL is the UML
  • expression / query language

17
History of OCL
  • Syntropy influenced by Z
  • Language for Business Modeling
  • IBM/ObjecTime OMG submission
  • Part of UML standard
  • Extended and formally defined for UML 2.0

18
OCL Characteristics
  • Ease-of-use
  • Readable and writeable by wide audience
  • Pure expression language
  • Side-effect free
  • Specification language
  • Declarative and platform independent
  • Precision
  • Unambiguous, formal (?)

19
Example Model
Bottle capacity Integer contents
Integer weight Integer diameter
Integer neckDiameter Integer totalWeight()
Integer
Crate capacity Integer maxWeight
Integer maxDiameter Integer totalWeight()
Integer addBottle(b Bottle)
0..1
0..
bottles
crate
crates
0..
bottle
0..1
pallet
0..1
cap
0..1
Pallet capacity Integer maxWeight
Integer totalWeight() Integer addCrate(c
Crate)
Cap innerDiameter Integer weight Integer
0..
/ caps
20
Invariants on Classes
  • context Crate
  • -- the number of bottles may not exceed its
    capacity
  • inv bottles-gtsize() lt capacity
  • -- each bottle must fit in the crate
  • inv bottles-gtforAll(diameter lt maxDiameter)
  • -- the total weight must be less than the maximum
  • inv totalWeight() lt maxWeight

21
Invariants on Classes
  • context Crate
  • -- each bottle must fit in the crate
  • inv bottles-gtforAll(diameter lt maxDiameter)
  • FORALL b Bottle FROM bottles
  • ISTRUE
  • b.diameter lt maxDiameter

22
State invariants
  • context Bottle
  • state Closed inv contents capacity

open
Bottle capacity Integer contents Integer
weight Integer diameter Integer
neckDiameter Integer totalWeight() Integer
closed
23
Design by Contract
  • Pre- and post-conditions
  • Takes Design by Contract principle into
    Analysis by Contract

24
Preconditions on Operations
  • context CrateaddBottle( b Bottle )
  • -- there must be room in the crate
  • pre bottles-gtsize() lt capacity
  • -- the maximum weight for the crate may not be
    exceeded
  • pre totalWeight() b.totalWeight() lt
    maxWeight
  • -- the bottle is not in the crate
  • pre not bottles-gtincludes( b )
  • -- b is added to the collection of
    bottlespost bottles bottles_at_pre-gtincluding(b)

25
Use Case Pre/Postcondtions
  • A use-case can be viewed as a system function.
  • Use case assumptions and results can be specified
    in OCL.

26
Components
  • Specified by an (or more) interface(s)
  • Operations with pre- and postconditions
  • Invariants on the objects described by the
    interface
  • Show business rules for the component
  • OCL 2.0 Message clause
  • Specify user visible side-effects

27
Business Rules
  • There may be at most as many caps with winner
    markers on a pallet as there are crates on the
    pallet
  • context Pallet inv
  • caps-gtselect(winnerMark true)-gtsize()
  • lt crates-gtsize()
  • SIZEOF
  • SELECT c Cap FROM self.caps
  • WHERE c.winnerMark true
  • lt
  • SIZEOF self.crates

28
Initial values and derivations
  • -- The caps in a pallet are derived
  • context Palletcap
  • derive crates.bottles.cap-gtasSet()
  • context Bottlecontents
  • init 0

29
Operation body
  • The body of a query operation can be specified in
    OCL
  • context BottletotalWeight() Integer
  • body weight cap.weight
  • context CratetotalWeight() Integer
  • body weight bottles.totalWeight()-gtsum()

30
Guards
open
Bottle capacity Integer contents
Integer weight Integer diameter
Integer neckDiameter Integer totalWeight()
Integer
close contentscapacity
closed
31
Expressions in a UML model
  • The target object in an interaction can be
    specified.
  • Object flows in activity diagrams
  • Parameters to messages and signals
  • etc.

32
Queries
  • OCL is a Query Language
  • Expressive power gt SQL
  • David Akehurst, Canterbury University
  • Boldsoft
  • Uses OCL exclusively as a query language to
    specify the user interface
  • Queries can be defined on the model level

33
Part 3 The MDA Framework
34
MDA
  • MDA is defined around
  • Models
  • Model Transformations
  • Important model types
  • PIM Platform Independent Model
  • PSM Platform Specific Model

35
Basic MDA Framework
36
MDA Framework
Transformation Tool
Source Model
Target Model
37
MDA
  • To enable this we need
  • Modeling languages
  • Transformation definitions

38
MDA Framework
Is used by
Source Model
Target Model
39
Defining Languages
model
Is written in
40
MDA Framework
Meta language
Is written in
Is written in
Is written in
Is written in
Is used by
Source Model
Target Model
41
Defining Transformations
  • A transformation definition maps
  • Element(s) from the source language
  • to
  • Element(s) from the target language
  • based on the respective language definitions

42
Is written in
Is written in
Is written in
Is written in
Is used by
Source Model
Target Model
Transformation tool
43
Complete MDA Framework
  • Languages are defined by models
  • These are metamodels, e.g. UML
  • These models are written in a metamodeling
    language
  • MOF is the OMGs metamodeling language
  • Transformation Definition Language
  • MOF RfP for Query/Views/Transformations

44
Part 3 OCL in MDA
45
OCL in MDA
  • OCL is essential for MDA in three ways
  • More precise models
  • Definition of Modeling Languages
  • Transformation definitions

46
Defining Languages
  • UML metamodel
  • Context Class inv
  • attributes-gtisUnique(name)

Class name Integer
owner
1
0..
attributes
Attribute name String
47
UML Metamodel Rules
  • 2 An AssociationClass cannot be defined between
    itself and something else.
  • self.allConnections-gtforAll(ar
  • ar.participant ltgt self)
  • 1 An Interface can only contain Operations.
  • self.allFeatures-gtforAll(f
  • f.oclIsKindOf(Operation) or
  • f.oclIsKindOf(Reception))

48
UML Profile Rules
  • Rules for e.g. Java profile
  • context Class inv
  • generalizations-gtsize() lt 1
  • Other profiles
  • EDOC, CORBA, C, EAI, UML-EJB, SPE, etc. etc.

49
Transformation Definition
50
Transformation Definitions
  • Transformation ManyAssociationToAttribute (UML,
    UML)
  • source ae UMLAssociationEnd
  • target att UMLAttribute
  • source condition
  • ae.multiplicity MultiplicityKindmany
  • target condition
  • att.visibility VisibilityKindpublic
    and att.type.isTypeOf(Set)
  • mapping
  • ae.name ltgt att.name
  • ae.type ltgt att.type.elementType

51
References
  • MDA Explained, Practice and Promise of the Model
    Driven Architecture
  • ISBN unknown, to appear Spring 2003, Kleppe,
    Warmer Bast
  • The Object Constraint Language, Precise Modeling
    with UML
  • ISBN 0-201-37940-6, 1999, Warmer Kleppe
  • The Object Constraint Language, Getting Your
    Models Ready for MDA
  • ISBN 0-321-17936-6, to appear May 2003, Warmer
    Kleppe
  • OCL 2.0 Submission
  • www.klasse.nl/ocl/subm-intro.html

52
Questions
53
Part 4 Current Status
54
OCL 2.0 Submission
  • Authoring Team

55
OCL 2.0 Submission
  • Submitters and supporters

56
OCL 2.0 Submission Highlights
  • Full UML query language
  • Complete OCL metamodel
  • ? full integration with UML metamodel
  • Concrete syntax strictly separated from abstract
    syntax
  • ? allows alternative syntaxes, including visual
    ones
  • Semantics defined mathematically and in UML

57
UML 2.0 Structure
  • Infrastructure (ad/00-08-08)
  • Simple and extensible UML core
  • Superstructure (ad/00-08-09)
  • Higher level UML structures
  • OCL (ad/00-08-10)
  • General purpose UML expression language
  • Diagram interchange (ad/00-08-11)
  • Exchange visual UML models between tools
Write a Comment
User Comments (0)
About PowerShow.com