Re: OCL challenge



Date view Thread view Subject view Author view

Mark Richters (mr@Informatik.Uni-Bremen.DE)
06 Dec 2000 13:09:48 +0100


Daniel Jackson <dnj@lcs.mit.edu> writes: > would someone like to give me some help writing OCL constraints? I have tried to write a specification with OCL for your model. It is availabe as http://db.informatik.uni-bremen.de/~mr/Lists.use This specification can be checked with the USE tool (see http://db.informatik.uni-bremen.de/projects/USE). For example, a valid snapshot can be generated with the following script http://db.informatik.uni-bremen.de/~mr/Lists.cmd A screenshot showing this state is here http://db.informatik.uni-bremen.de/~mr/lists_state.gif > it's not clear exactly how to draw this, since not all Lists contain > Pairs, but the Lists contained by Maps do. one of the issues my > paper addresses is how to make solve this problem, so thoughts on > that also welcome. I have changed the model, so that Object is the parent of all other classes. The element of a NonEmptyList now is an Object. If the list is part of a map, then the element's class must be Pair which is a subclass of Object. This way, you can also put lists into lists, etc. The resulting class diagram can be seen in http://db.informatik.uni-bremen.de/~mr/lists_classes.jpg (not exactly UML, it has been automatically generated from the textual specification). I don't claim that my solution is elegant. There are a number of type casts required making the constraints hard to read. These don't seem to be necessary in Alloy. To what degree does Alloy provide static type checking? I first stumbled across the expression "list.*next" which appeared strange to me, because next is defined only for NonEmptyLists. Regards, Mark -- Mark Richters (mr@informatik.uni-bremen.de)


Date view Thread view Subject view Author view