Design by Contract in Smalltalk

In the context of object-oriented programming languages we propose an extension of the Smalltalk environment which provides for the possibility of constructing software by applying the Design by Contract methodology , introduced by Meyer as a way of developing reliable software. In this sense, both correctness and robustness are increased by using the mechanisms incorporated to Smalltalk as a consequence of the proposed extension. Thus, assertions are used to guarantee the preconditions and postconditions of methods and the stability of the state of the objects, while a mechanism is provided in order to handle the exceptional situations. The Smalltalk programming philosophy is maintained, and the extension does not alter the basic concepts distinguishing this language from the rest of object-oriented languages. This means that the new possibilities incorporated to the environment are accessible by invoking appropriate methods on certain objects. Basic constructions of the language do not need to be modiied, so avoiding special sections in the method syntax. The management of execution control has been handled by using the Smalltalk language itself in a transparent way. Therefore, the extension may be easily applied to other Smalltalk systems.