Join Books.org — it's free

Object-Oriented Programming, CAD/CAM - General & Miscellaneous, CAD/CAM
Design by Contract, by Example by Richard Mitchell β€” book cover

Design by Contract, by Example

by Richard Mitchell, Jim McKim
Write a review
Log in to track your reading progress.

Overview

Design by contract is an underused--but powerful--aspect of the object-oriented software development environment. With roots in the Eiffel programming language, it has withstood the test of time, and found utility with other programming languages. Here, by using both the Eiffel and Java languages as guidance, Design by Contract, by Example paves the way to learning this powerful concept.

Through the following six teaching principles, the authors demonstrate how to write effective contracts and supporting guidelines. Readers will learn how to:

  1. Separate queries from commands
  2. Separate basic queries from derived queries
  3. Write a postcondition for each derived query that specifies what result can be returned
  4. Write a postcondition for each command that specifies the value of every basic query
  5. Decide on a suitable precondition for every query and command
  6. Write invariants to define unchanging properties of objects

Contracts are built of assertions, which are used to express preconditions, postconditions and invariants. Using the above principles, the authors provide a frank discussion of the benefits, as well as the potential drawbacks, of this programming concept. Insightful examples from both the Eiffel and Java programming languages are included, and the book concludes with a summary of design by contract principles and a cost-benefit analysis of their applications.

Design by Contract, by Example is the first book of its kind to offer an example-based approach to learning this important paradigm. If you are a developer seeking a way to improve your craft, this book will give you the necessary understanding of the concepts of contracts in software design.

0201634600B08142001

Synopsis

What the Book Covers

Design by Contract is all about adding assertions to object-oriented programs at the design and coding stages. Assertions are facts about a program that must be true for the program to be bug-free. The key assertions in Design by Contract define preconditions, postconditions, and invariants:

  • A precondition is a condition on a method specifying what must be true for it to be valid to call the method.
  • A postcondition is a condition on a method specifying what will become true when the method successfully completes.
  • An invariant is a condition on a whole class specifying what is true about any object of the class whenever you can call a method on that object. The assertions are written in a programming language, so:
  • They make sense to programmers, providing good, helpful documentation
  • They are checkable at runtime, providing support for testing and debugging.

  • About the Author, Richard Mitchell

    Richard Mitchell is a senior consultant with InferData Corporation, specializing in object-oriented analysis and design. Before joining InferData full-time in 1999, he was a Professor of Computing at the University of Brighton, UK, where he was involved in teaching and researching object technology.

    Jim McKim is Clinical Professor and Chair of the Department of Engineering and Science at Rensselaer Polytechnic Institute in Hartford, Connecticut. He has been teaching and consulting in the area of object oriented software development for some 10 years. Over the same period he has authored or coauthored numerous articles on Design by Contract for such publications as the Journal of Object-Oriented Programming and IEEE Computer.

    Reviews

    There are no reviews yet. Log in to write one.

    Book Details

    Published
    October 1, 2001
    Publisher
    Addison-Wesley
    Pages
    256
    Format
    Paperback
    ISBN
    9780201634600

    More by Richard Mitchell

    Similar books