In the past, objections have been raised about the syntax of OCL. Some find it too difficult, others find it too different from mathematical languages. As it is, the OCL standard separates the concepts in the language from the concrete syntax used. This means that alternative concrete syntaxes can be made available. OCL expressions written in such an alternative syntax have exactly the same meaning as expressions written in the standard syntax. To give an example and demonstrate the feasibility of this approach, a syntax has been devised that is aimed at the business modeler. The alternative syntax, from here on called the business modeling (BM) syntax, resembles the outward appearance of SQL, but supports all of the concepts in OCL. The main difference between the official syntax and the business modeling syntax is the notation for the predefined operations on collections and for the predefined iterators (loop expressions). Another difference is the absence of the implicit collect . Every collect operation needs to be explicitly stated. To give you a first feel for the syntax, one of the expressions from Chapter 2 ("OCL By Example") is shown here in the business modeling syntax: context Customer inv : size of programs = size of select i: CustomerCard from cards where i.valid = true In the standard OCL syntax, this would be context Customer inv : programs->size() = cards->select( i.valid = true ) All examples given in this appendix are based on the R&L example from Chapter 2 ("OCL By Example"). As a convenience, we repeat the diagram for the R&L example in Figure C-1. Figure C-1. The Royal and Loyal model
|