In accordance with Nicolas Rouquette's observations in the discussion on "15233 – OCL 2.2 Correction to Issue 9796 for AssociationEndCall":
The problem with OCL 2.2, Fig 7.1 are:
- give a name to the association end near Bank, e.g. 'bankAccount'
- fix the multiplicity of: Person::bankAccount from 0..1 to * – i.e., a person can have zero or more bank accounts!
- fix the multiplicity of Bank::customer from 0..* to 0..1 – i.e., there is zero or one customer for a given 'accountNumber' value.
- give a name to the association itself, e.g., BankAccount, or, if you want to use the UML notation convention, A_customer_bankAccount
and
The OCL examples for Figure 7.2, currently:
context Person inv: self.employeeRanking[bosses]->sum() > 0
context Person inv: self.employeeRanking[employees]->sum() > 0
context Person inv: self.employeeRanking->sum() > 0 – INVALID!
context Person inv: self.job[employer]
should be fixed to:
context Person inv: self.EmployeeRanking[bosses]->sum() > 0
context Person inv: self.EmployeeRanking[employees]->sum() > 0
context Person inv: self.EmployeeRanking->sum() > 0 – INVALID!
context Person inv: self.Job[employer]
That is, 'EmployeeRanking' is the name of the association shown in Fig 7.2
That figure does not have anything called 'employeeRanking' and it is misleading to suggest that in OCL the name of the association could be written with a lowercase initial letter when the name of the association itself has an initial capital letter. Since lexical names are case-sensitive in both UML and OCL, case-sensitivity should be respected to avoid creating confusion and potential ambiguity with other names that are lexically different only by their upper/lower case letter.
and
In particular, the text in clause 7.5.4 about using the name of an association class with a lowercase initial letter should be removed.
That is, change the following, currently:
To specify navigation to association classes (Job and Marriage in the example), OCL uses a dot and the name of the association class starting with a lowercase character:
context Person inv: self.job
The sub-expression self.job evaluates to a Set of all the jobs a person has with the companies that are his/her employer. In the case of an association class, there is no explicit rolename in the class diagram. The name job used in this navigation is the name of the association class starting with a lowercase character, similar to the way described in the sub clause “Missing AssociationEnd names” above.
to:
To specify navigation to association classes (Job and Marriage in the example), OCL uses a dot and the name of the association class:
context Person inv: self.Job
The sub-expression self.Job evaluates to a Set of all the jobs a person has with the companies that are his/her employer. In the case of an association class, there is no explicit rolename in the class diagram. The name Job used in this navigation is the name of the association class.