Does anyone know good Object Constraint Language (OCL) tutorial?

Artur picture Artur · May 23, 2009 · Viewed 7.5k times · Source

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:

  1. Everybody working in the department has the same manager.
  2. Nobody in the company is the manager of him/herself.
  3. Nobody in the company earns more than his manager.

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.

Answer

Artur picture Artur · May 23, 2009

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 :)