views:

47

answers:

2

I am trying to wrap my head around why we first approach the problem of design and decide upon a visual method (UML), instead of starting with formal specifications that happen to also be executable (RAD prototyping), we start with diagrams that can't be easily proven to work. So when it comes time to prove properties of a model, we find we need to define constraints into our design, so we design a formal syntax (OCL) to define the constraints on the model. I am having a hard time understanding this leap back to where we started. I find OCL encumbered UML designs (even samples shown in brochures) unreadable, even more impenetrable than the myriad of UML symbols and conventions. So what I want to know is: What are the key areas where OCL is used in the working software development world today, and for whom is it relevant or worthwhile to learn? What does your job role look like? Do architects who never write code use UML and OCL, or do programmers who also design and architect the systems with the same team that implements it, use it too?

[updated: Secondly, it occurs to me that Agile development seems kind of opposed to "Heavyweight" procedures, and that a domain specific language for design diagram constraints like OCL doesn't seem very Agile. Is UML+OCL used in ANY "Agile" shops, or is it universally eschewed by Scrummers?]

+2  A: 

Interesting question.

The "holy grail" of the Object Constraint Language was to provide a framework that when coupled with UML allowed a tool to transform that into a concrete Object Graph / Meta Model i.e. a set of classes that already had their basic structure and constraints wired in, so that all the developer had to do was implement business methods. (all this in a language independent way)

JBuilder from Borland tried supoprting this in their enterprise edition, and Delphi with ECO also made use of OCL in a practical way (though not as a transformation input) by supporting the Query abilities. In fact Anders Inver from Borland / BoldSoft, and one of the ECO team, wrote the forward on the OCL bible, The Object Constraint Language, Second Edition (addison wesley)

My personal opinion is that there is not enough pay back to warrant the learning curve. Without using specialised (and expensive) tools the UML/OCL model is still not easily testable in real terms, and the value you get is marginal (if anything) over itterative test driven development. The language independence thing is waaay overrated, lets face it once we start down the Java, C#, Delphi, C++ or whatever path, there is no way in hell we will re-generate in something else, its just not practical.

For what its worth, I am yet to see Model Driven Development with OCL actually used in the real world for a real project. (other than as a proof of concept) What seems to be working lately in the real world is Agile processes, Scrum etc and just itterative development using standard IDE's with standard languages and user stories (perhaps some UML on a whiteboard or storyboard).

Tim Jarvis
IF someone gave me the job of crafting OCL I would not have invented a new syntax. I would have just used Python. You could use a Python script and existing python lexers/yacc to parse the python syntax and generate any other language you wanted.
Warren P
The holy grail can be more generally put as giving modelers a language for creating model specifications, which would enable better semantics than the model alone. Actually this helps avoiding ambiguity in models and especially in UML helps to create profiles. Not to forget, OCL can be also seen as an OO query language.I personally think the language is not hard, but the tool support is lacking. IMHO language independence is interesting, take for example integration projects.Look e.g. at Eclipse TMF Xtext, it enables creation of checks for DSLs using a language very similar to OCL.
Gabriel Ščerbák
°@Warren P you could do that in any language, the point is, that OCL allows for easy navigation over associations, enables declarative operations on collections, gives you pre/post condtions and invariants and guaranties no side effects on the model, that I think you do not get out of the box in any OO language.
Gabriel Ščerbák
+2  A: 

The benefit of defining OCL constraints on your models is the possibility of specifying all the business rules of your domain that you cannot represent with the graphical constructs of the UML (for instance, multiplicities are constraints that can be graphically represented as part of an association definition, saying that the attribute A of class C has to be greater than 5 is also a constraint but in this case has to be defined in OCL since UML does not provide a graphical syntax for this)

Obviously, this would be very useful if code-generation tools would be able to take these constraints and automatically generate a code that enforces them (e.g. as if-conditions in Java methods or as triggers in databases that raise an exception when the data violates the rule).

Unfortunately, there aren't many tools offering this functionality (see a list here: http://modeling-languages.com/content/list-ocl-tools) but the situation is slowly improving

Jordi Cabot
+1 for helpful answer. It would be useful if they did use it, which they don't, so one learns a syntax, only so that a diagram could become more useful in the future than it would be now if we just made a note, and yet it's less readable than a human language note: "Must have 5 grues per snark".
Warren P
maybe it is less readable but it is also mor precise. Natural language is ambiguos
Jordi Cabot
so are diagrams. not so much ambiguous but it is generally unclear when they are incomplete or mutually inconsistent. so doesn't that make RAD prototyping (unambiguous) better than a combination of unambiguous constraints, and possibly ambiguities and overlooked details (the latter much more likely of course) in a UML diagram?
Warren P
probably this is a complex discussion but RAD prototyping is not the ideal solution either (the user can play with that but the tests will be always incomplete, it may happen the user does not try a given scenario and thus the error is only discovered afterwards)
Jordi Cabot
To add to this discussion, imho it could be possible to generate unit tests from OCL (if fixtures are given) or design by contract code and that would make OCL especially interresting to analysts, testers and developers, since it would be one universal language to learn for non-programmers and developers would have executable specifications.
Gabriel Ščerbák