ABS++ : Assertion Based Subtyping in C++.
Herbert Toth · The Journal of Object Technology · 2006
For software engineering to meet today's challenges, well designed reuse and composition mechanisms must be established in both theory and practice.Starting roughly ten years ago, theoretical principles and solution possibilities for assertion annotations in daily practice are being discussed in an ever growing number of papers and web pages.We present a further proposal for C++ that is based on the macro technique, conforms to the LSP, enables quantification, and very much resembles the way Design by Contract TM is implemented in Eiffel.J OURNAL OF OBJECT TECHNOLOGY V OL. 5, NO. 6What is Design by Contract TM ?"Design by Contract" denotes a software development style which (1) emphasises the importance of formal specifications, and (2) interleaves them with actual code.DbC is a systematic method of assertion usage and interpretation introduced by Bertrand Meyer as a standard feature of the Eiffel language.Without it, no trial would have ever been made to provide a similar mechanism in other languages and, by no means, would we have discussion papers like this and the ones mentioned in the references.A software contract is the specification of the behavior of a class and its associated methods.The contract outlines the responsibilities of both the caller and the method being called.Failure to meet any of the responsibilities stated in the contract results in a breach of the contract, and indicates the existence of a bug somewhere in the design or implementation of the software or -one must not forget -in the assertions themselves.Software contracts can be completely specified by preconditions, postconditions, and class invariants.Software construction is based on contracts between clients and suppliers.Each party expects some benefits from the contract, and accepts some obligations in return.As in human affairs, the contract document spells out these mutual benefits and obligations and protects both he client, by specifying how much should be done, and the supplier, by stating that the supplier is not liable for failing to carry out tasks outside of the specified scope.DbC is, in a way, the opposite of defensive programming, a method which recommends to protect every software module by as many checks as possible.This may result in redundancy and makes it also difficult to precisely assign responsibilities among modules.Software contracts are also a necessary prerequisite for introducing a notion of correctness: If you do not state what your program should do, you are lacking the norm to which to compare what your program does in reality. Contracts and inheritance