Extending a method of devising software contracts

Classes in object-oriented programs can be specified using assertions, specifically, preconditions and postconditions on individual methods and invariants on whole classes. Such assertions can be seen as forming a contract between a class and its client classes and, by extension, between the developers of class and the developers of client classes. In some programming environments, the contracts can be checked at runtime. A published method of devising contracts is applied to a small framework based on the observer pattern, raising a number of problems of writing contracts for a set of collaborating classes, rather than for individual classes such as those formed in data structure libraries. As well as providing an example of tackling such problems, the paper identifies desirable extensions to the method of devising contracts, to address aspects of performance (keeping the run-time cost of evaluating preconditions low); privacy (ensuring that one client of a class cannot discover the identities of other clients); extensibility (allowing subclasses to weaken preconditions without invalidating existing postconditions, and allowing subclasses to adopt different frame rules); and kinds of constraints (distinguishing physical and logical constraints).

[1]  Jean-Marc Jézéquel,et al.  Design by Contract: The Lessons of Ariane , 1997, Computer.

[2]  Jean-Marc Jézéquel,et al.  Self-testable components: from pragmatic tests to design-for-testability methodology , 1999, Proceedings Technology of Object-Oriented Languages and Systems. TOOLS 29 (Cat. No.PR00275).

[3]  Tommi Mikkonen,et al.  Formalizing design patterns , 1998, Proceedings of the 20th International Conference on Software Engineering.

[4]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[5]  簡聰富,et al.  物件導向軟體之架構(Object-Oriented Software Construction)探討 , 1989 .

[6]  Richard Mitchell,et al.  Contract-oriented specifications , 1997, Proceedings. Technology of Object-Oriented Languages. TOOLS 24 (Cat. No.97TB100240).

[7]  William E. Lorensen,et al.  Object-Oriented Modeling and Design , 1991, TOOLS.

[8]  Anneke Kleppe,et al.  The object constraint language: precise modeling with UML , 1998 .

[9]  Desmond D'Souza,et al.  Objects, Components, and Frameworks with UML: The Catalysis Approach , 1998 .

[10]  John Mylopoulos,et al.  On the Frame Problem in Procedure Specifications , 1995, IEEE Trans. Software Eng..

[11]  Ken Arnold,et al.  The Java Programming Language , 1996 .

[12]  Jos Warmer,et al.  The object constraint language , 1998 .

[13]  Wilf R. LaLonde,et al.  Programming by Contract: Designing for Correctness. , 1996 .

[14]  강문설 [서평]「The Unified Modeling Language User Guide」 , 1999 .

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

[16]  Bertrand Meyer,et al.  Eiffel: The Language , 1991 .