Presentation is loading. Please wait.

Presentation is loading. Please wait.

Jairson Vitorino, Cin UFPE May, 2nd 2005

Similar presentations


Presentation on theme: "Jairson Vitorino, Cin UFPE May, 2nd 2005"— Presentation transcript:

1 Jairson Vitorino, Cin UFPE May, 2nd 2005
OCL in a small nutshell Jairson Vitorino, Cin UFPE May, 2nd 2005

2 Contents Motivation What is OCL? Uses of OCL Examples References

3 Are you serious about your UML models? (source: www.empowertec.de)
Motivation Are you serious about your UML models? (source:

4 What is OCL? The Object Constraint Language (OCL) is a query language that can be used to define expressions on object oriented models (UML). OCL enrich the models with unambiguous information, formalizing knowledge about the underlying business domain.

5 It is a formal language, but Yes! You can understand it and even use it!

6 Uses of OCL Constraints are the most prominent use.
Initialization expressions can be used to specify an initial value for an attribute or an association. OCL expressions can be used to specify the algorithm that is to be used for derived attributes, i.e. values that are calculated from other attributes or associations. OCL expressions can be used to specify the implementation of methods as long as they do not have side effects (i.e. the method is 'read only').

7 A trivial Example context Stack::pop(): Object
optional You can refer to the previous state of na object context Stack::pop(): Object pre notEmpty: isEmpty() = false post topElementReturned: result = post topElementRemoved: top() <>   context Stack::top(): Object pre notEmpty: isEmpty() = false   context Stack::push(anObject: Object): void post pushedObjectIsOnTop: top() = anObject

8 A more typical example

9 And typical constraints...
No employee may be older than 65 years OCL equivalent context Company inv: self.employee->forAll(age <= 65) And what about this one? What does it mean? context Company inv: employee->exists(isUnemployed) = false

10 More examples in the PDF

11 Tools Octopus : Plug-in for Eclipse OCLE:
(syntatical checking on class diagrams, cool editor and generates java code!) OCLE: From Romenia, syntantical checking, model checking, comes with full UML meta-model and well-formdness rules for diagrams consistency in OCL! Generates java code) OCL-AddIn for Rational Rose, similar to Octopus but do not generate code.

12 Conclusions and further motivation
UML without OCL is only useful for extreme programming, disposable models OCL is key for formal methods, UML models as first-class, strategic, reusable artefacts and (future) automated code generation

13 References http://www.omg.org http://www.empowertec.de
Presentation Object Constraint Language (OCL) by Tevfik Bultan ( Introduction to OCL, Andreas Roth (i12www.ira.uka.de/~aroth/ lehre/keypraktWS0304/oclIntro.pdf)


Download ppt "Jairson Vitorino, Cin UFPE May, 2nd 2005"

Similar presentations


Ads by Google