Strengthening Method Contracts for Objects
Atul Kumar Gupta, Amit Raj · 2006
The main objective of a 'design by contracts' approach as applied to object-oriented systems, is to develop complete and consistent method contracts for the objects of the system. In this work, we propose a practical approach to develop these contracts for an object from its annotated structural representation, namely, UML constrained class diagram. We generate, simulate, and refine an object state-chart from an initial set of method contracts which in turn help further validating and enhancing these contracts. The impact of this analysis can be multifold: first, it identifies various discrepancies like incomplete and inconsistent class specifications, second, a correct and consistent object statechart model is obtained from which reliable automated code and unit tests can easily be generated, third, facilitate essential and effective verification for software re-use, forth, the resulting statechart and class specifications are in a lock-steps which facilitates effective incremental development and change management and fifth, it allows a modeler to specify object's dynamic requirements declaratively on an abstract level, without the need to use full operational dynamic diagrams. We have also designed a tool ObjectSim that performs automated statechart generation and their interactive simulations. We demonstrate our approach using an example and discuss other related issues.