• DocumentCode
    3352706
  • Title

    Simple support for design by contract in C++

  • Author

    Guerreiro, Pedro

  • Author_Institution
    DEpt. de Inf., Univ. Nova de Lisboa, Portugal
  • fYear
    2001
  • fDate
    2001
  • Firstpage
    24
  • Lastpage
    34
  • Abstract
    Design by contract can be seen as an advanced software engineering technique for building quality software in a professional environment or as a fundamental programming concept, useful even for elementary programming. If design by contract is an afterthought, sophisticated tool support, with macros, preprocessors or patterns is acceptable. If it is to be used from the very first programs, it must not be yet another difficult obstacle to the novice programmer. This point of view seems to recommend Eiffel as the sole vehicle for the early introduction of design by contract. However, compromises are possible, if your organization mandates C++, for example. For design by contract in C++ we use a class template, Assertions ⟨T⟩, which is inherited by the classes we are specifying. This class handles preconditions, postconditions and class invariants, and supports the “old” notation. The assertions themselves are not difficult to implement but the “old” notation, which is necessary in order to compare the value of an attribute in a postcondition with its value at an earlier stage in the function, raises interesting issues. In most common situations, using the assertions is straightforward. There are, however, more rare cases involving inheritance and recursion that must be handled with a discipline
  • Keywords
    abstract data types; object-oriented programming; software engineering; C++; assertions; class invariants; class template; design by contract; inheritance; postconditions; preconditions; professional environment; quality software building; recursion; software engineering technique; Computer languages; Contracts; Design engineering; Java; Libraries; Programming profession; Software design; Software quality; Software tools; Vehicles;
  • fLanguage
    English
  • Publisher
    ieee
  • Conference_Titel
    Technology of Object-Oriented Languages and Systems, 2001. TOOLS 39. 39th International Conference and Exhibition on
  • Conference_Location
    Santa Barbara, CA
  • ISSN
    1530-2067
  • Print_ISBN
    0-7695-1251-8
  • Type

    conf

  • DOI
    10.1109/TOOLS.2001.941656
  • Filename
    941656