Executable visual contracts

Design by contract (DbC) is widely acknowledged to be a powerful technique for creating reliable software. DbC allows developers to specify the behavior of an operation precisely by pre- and post-conditions. Existing DbC approaches predominantly use textual representations of contracts to annotate the actual program code with assertions. In the unified modeling language (UML), the textual object constraint language (OCL) supports the specification of preand post-conditions by constraining the model elements that occur in UML diagrams. However, textual specifications in OCL can become complex and cumbersome, especially for software developers who are typically not used to OCL. In this paper, we propose to specify the pre-and post-conditions of an operation visually by a pair of UML object diagrams (visual contract). We define a mapping of visual contracts into Java classes that are annotated with behavioral interface specifications in the Java modeling language (JML). The mapping supports testing the correctness of the implementation against the specification using JML tools, which include a runtime assertion checker. Thus we make the visual contracts executable.

[1]  Heinrich Hußmann,et al.  Modular architecture for a toolset supporting OCL , 2000, Sci. Comput. Program..

[2]  Albert Zündorf,et al.  Graph Pattern Matching in PROGRES , 1994, TAGT.

[3]  Gary T. Leavens,et al.  A Simple and Practical Approach to Unit Testing: The JML and JUnit Way , 2002, ECOOP.

[4]  Richard G. Hamlet,et al.  Automatically Checking an Implementation against Its Formal Specification , 2000, IEEE Trans. Software Eng..

[5]  Reiko Heckel,et al.  Concurrency and loose semantics of open graph transformation systems , 2002, Mathematical Structures in Computer Science.

[6]  Ivar Jacobson,et al.  The Unified Software Development Process , 1999 .

[7]  Albert Zündorf,et al.  Story Diagrams: A New Graph Rewrite Language Based on the Unified Modeling Language and Java , 1998, TAGT.

[8]  Stuart Kent,et al.  Spider Diagrams: A Diagrammatic Reasoning System , 2001, J. Vis. Lang. Comput..

[9]  Marieke Huisman,et al.  Reasoning about Java programs in higher order logic using PVS and Isabelle , 2001 .

[10]  MeyerBertrand,et al.  Design by Contract , 1997 .

[11]  David Lorge Parnas,et al.  Using Test Oracles Generated from Program Documentation , 1998, IEEE Trans. Software Eng..

[12]  Bertrand Meyer,et al.  Applying 'design by contract' , 1992, Computer.

[13]  Albert L. Baker,et al.  Preliminary design of JML: a behavioral interface specification language for java , 2006, SOEN.

[14]  Gabriele Taentzer,et al.  A Visualization of OCL Using Collaborations , 2001, UML.

[15]  J. van Leeuwen,et al.  Theory and Application of Graph Transformations , 1998, Lecture Notes in Computer Science.

[16]  Michael D. Ernst,et al.  An overview of JML tools and applications , 2003, International Journal on Software Tools for Technology Transfer.

[17]  Ali Hamie,et al.  Translating the Object Constraint Language into the Java Modelling Language , 2004, SAC '04.

[18]  Stuart Kent,et al.  Mixing Visual and Textual Constraint Languages , 1999, UML.

[19]  Manfred Nagl,et al.  Graph-Grammars and Their Application to Computer Science , 1982, Lecture Notes in Computer Science.