I came across couple of questions about OCL expressions. After reading some university slides and googling it I still cannot properly understand it.
I wonder if any of you guys know any good resources that I should read to understand this stuff.
Constraints that bother me:
For the 1st one I have:
context Department
inv self.stuff -> forAll(manager = self.staff.manager)
2nd one:
context Company
inv self.employee -> select(manager = manager.manager) -> isEmpty()
3rd one:
context Company
inv self.employee -> select(salary > manager.salary) -> isEmpty()
but I dont think these are right. What I'm most unsure of is whether in example 2 and 3 I actually compare individual employees with theirs actual manager / manager salary.
OCL is part of Unified Modeling Language (UML) and it plays an important role in the analysis phase of the software lifecycle. languages can use OCL to specify constraints and other expressions attached to their models. OCL is the expression language for the Unified Modeling Language (UML).
The Object Constraint Language (OCL) is a declarative language describing rules applying to Unified Modeling Language (UML) models developed at IBM and is now part of the UML standard. Initially, OCL was merely a formal specification language extension for UML.
OCL is a typed, declarative and side-effect free specification language. Typed means that each OCL expression evaluates to a type (either one of the predefined OCL types or a type in the model where the OCL expression is used) and must conform to the rules and operations of that type.
The OCL is used to represent constraints in the UML class diagram. Therefore, we parse OCL constraints and translate them into AsmL in order to enforce these constraints on the instance-level diagrams.
Finally got something good!
This is very informative document (PDF) from Object Management Group (OMG):
Object Constraint Language Specification
I love answering my own questions :)
The link to PDF file posted by @Artur has changed, Here is new link http://www.omg.org/spec/OCL/2.0/PDF/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With