Tricia Balfe explains us today how to get more out of our OCL rules with Nomos (another reason to learn OCL). Enjoy!
OCL is great for modellers who want to ensure models are correct. But it’s also really valuable as a way to model more. Plenty of organisations build data models. Using OCL, you can add business rules to the data models. The models are more complete, and the OCL can be used to generate executable rulesets for use in downstream systems: either test or production.
This streamlines the process of managing rules in a system. The modellers and analysts, who understand the domain, can define the rules completely in the model, execute and test them, and then deploy. It’s real division of labour resulting in real efficiencies. No more handing over ambiguous textual descriptions of rules to programming teams, with all the duplication of effort that that entails.
Here’s an example of a very simple MagicDraw model that includes OCL rules. It models a file containing bank ‘payment’ requests or payments records
And to see the rules in the MagicDraw environment in a little more detail:
At Nomos, we build products that generate executable java rulesets from OCL. The products currently support execution of OCL invariants and OCL queries over XML data – where the XML conforms to an XML schema, and the XML schema is a model transformation as in the diagram below.
The rulesets can be deployed as java archives, or can be deployed behind the Nomos Validation Web Service. By building a simple Web Service client, the rulesets can be called from any platform. The client passes an XML file to the web service, identifying the ruleset(s) against which the XML file needs to be validated, and is returned a list of errors.
The Nomos RuleX product provides the capability of building and executing these OCL-based rulesets. For MagicDraw users who want to build rulesets directly from MagicDraw, we provide the Cameo OCL Transformer, and for IBM RSA users, we provide the OCL Transformer for IBM RSA.
Here’s an online test service for payments messaging that built with OCL business rules. The test service is used by banks and corporates around Europe to test payments messaging. The messages are modelled in UML and XML schema, and the service is built using OCL business rules that describe the validation checks that the XML payments must comply with.
So OCL isn’t just useful to make sure models are correct. Models can be extended to include OCL business rules: the models are more complete, and you can generate executable rulesets from them. The rulesets are defined by domain experts, and can be reused across projects and applications. The potential for reuse and the resulting cost savings is enormous and easily justifies some extra effort in the modelling phase to make the models more complete.