Monday, March 16, 2009

UML Object Constraint Language

I’m using Object Constraint Language (OCL) for a small MDA project. OCL is a constraint language for UML and part of the standard. I have a small experience in F# and OCL reminds me to functional languages.

Wikipedia definition for OCL:

The Object Constraint Language (OCL) is a declarative language for describing rules that apply to Unified Modeling Language (UML) models developed at IBM and now part of the UML standard. Initially, OCL was only a formal specification language extension to UML. OCL may now be used with any Meta-Object Facility (MOF) Object Management Group (OMG) meta-model, including UML. The Object Constraint Language is a precise text language that provides constraint and object query expressions on any MOF model or meta-model that cannot otherwise be expressed by diagrammatic notation. OCL is a key component of the new OMG standard recommendation for transforming models, the Queries/Views/Transformations (QVT) specification.

So OCL is a declarative language. And functional languages are subsets of these. Here is a typical OCL expression:

Team.allInstances()->forAll( t | t.name = ‘teamname’)

It reminds me a lambda expression. t | t.name in F# is something like t –> t.name.

Now I’m sure it worths learning new paradigms like functional programming. You never know what kind of language (element) you have to use in the future.

No comments:

Post a Comment