Here are a few of the most unsettling language particularities :
Operations or features conflicting with reserved OCL keywords (UML anyone?). For example, if your model has a class "Operation" with a feature named "body", then writing "myClass.body" in OCL will result in a somewhat cryptic error : "invalid token 'body'".
The trick to access such features in OCL is to prefix the feature name with an underscore. For this example, you should have written "myClass._body".
For the record, the full list of OCL reserved keywords as per the last available OCL version, 3.0, is as follows :
- and
- body
- context
- def
- derive
- else
- endif
- endpackage
- if
- implies
- in
- init
- inv
- let
- not
- or
- package
- post
- pre
- static
- then
- xor
- Accessing enumeration values. This might sound obvious to OCL experts, but how would one compare feature values to set enumerated values? The trick here is to qualify the access. For example if you wish to check that an UML operation's visibility is "public", here is what you would do in Java : "if (operation.getVisibility() == VisibilityKind.PUBLIC".
The OCL equivalent is "if (operation.visibility = VisibilityKind::public)".
- There is no "elseif" in OCL ; remember to close each individual if properly with endifs : "if (...) then ... else if (...) then ... else ... endif endif"
Excuse me, but WTF is OCL? I know I could just google it, but I think your posts would greatly benefit from some title tags or at least define your TLAs on first usage.
ReplyDelete(I've read your post via the Eclipse Planet, in case you were wondering.)
@PAStheLoD : it's true that this message was more aimed at modeling people, and I admit I've been totally corrupted by acronyms ... not even realizing I use TLAs anymore :p.
ReplyDeleteI've added hyperlinks to the eclipse wiki for OCL and Acceleo ^^
thank you SO much
ReplyDeleteThumbs up
ReplyDelete