- Paperback: 256 pages
- Publisher: Addison-Wesley Publishing Company; 1st edition (October 22, 2001)
- Language: English
- ISBN-10: 0201634600
- ISBN-13: 978-0201634600
- Product Dimensions: 7.4 x 0.7 x 9 inches
- Shipping Weight: 1 pounds
- Average Customer Review: 3.3 out of 5 stars See all reviews (8 customer reviews)
- Amazon Best Sellers Rank: #2,455,018 in Books (See Top 100 in Books)
Enter your mobile number or email address below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.
To get the free app, enter your mobile phone number.
Design by Contract, by Example 1st Edition
Use the Amazon App to scan ISBNs and compare prices.
See the Best Books of 2017 So Far
Looking for something great to read? Browse our editors' picks for the best books of the year so far in fiction, nonfiction, mysteries, children's books, and much more.
Customers who viewed this item also viewed
What other items do customers buy after viewing this item?
From the Back Cover
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:
- Separate queries from commands
- Separate basic queries from derived queries
- Write a postcondition for each derived query that specifies what result can be returned
- Write a postcondition for each command that specifies the value of every basic query
- Decide on a suitable precondition for every query and command
- 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.
About the Author
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.
Browse award-winning titles. See more
If you are a seller for this product, would you like to suggest updates through seller support?
Top customer reviews
I like the fact that the book is well organized, and easily digestible (less than 250 pages). In contrast, the classic work on this topic,Object-Oriented Software Construction (Book/CD-ROM) (2nd Edition), goes into much greater depth on a variety of programming topics. I love that book, but it is enormous and probably too intimidating for many beginners.
I use contracts on a regular basis in my commercial programming. I have started using the six principles and five guidelines explained in the book as a checklist to evaluate my current product code. In doing so, I am looking at my code through a fresh set of eyes, finding weaknesses, and improving the clarity and reliability of the code.
Response to some of the criticisms given in other reviews:
"Not enough material, March 9, 2006" -
While I sympathize with many of the complaints of this reviewer, I still believe this book is a great introductory text for people who are learning to program contracts. Perhaps it would have been helpful to have examples of code contracts in more diverse domains rather than yet another example of the stack and the queue. This sounds like an opportunity to either expand the book in a second edition. Or another author may take advantage of this opportunity.
"I think contracts are not very strong tool, May 23, 2005"
As a commercial programmer who uses contracts and real product code, I can testify that the ideas in this book ARE practical in commercial applications. I have never found contracts to be too complex or hard to maintain. Admittedly there are problems in computer science with contracts do not solve. Contracts are not a magical silver bullet. Yet they remain very powerful and useful.
Most of the examples presented in the book are written in Eiffel, an object oriented language that fully supports preconditions, postconditions and invariants without need for preprocessing. If you haven't written code in Eiffel I highly recommend that you download EiffelStudio and deploy the examples in this book. Although there are tools that offer assertion facilities, none provide the ease of use as that seen in the Eiffel language. The text covers a preprocessor that imparts assertions to Java, but the extra steps and unique keywords required to incorporate and activate the assertions are likely to prevent wide scale use of the tool in a software development environment.
Some aspects of object oriented languages such as design by contract and multiple inheritance are often taught through a language and an integrated developer's environment that minimally supports the functionality. As such developers form a poor opinion of the concept and not the tool. The keyword support of contracts in Eiffel makes the language a perfect learning tool which will impart a more than academic understanding of the value of assertions.
The authors state ardently that developers have a choice between spending hours hunting down the causes of runtime errors or instead allocating time to write thorough contracts. As a sometimes Eiffel developer I can state that this assertion is accurate. Since contracts also assign responsibility for the runtime errors, they are invaluable for debugging. I recall an instance when I encountered a postcondition violation while using a linked list from the Eiffel library. As a client of the class, I didn't spend any time tracking down the source of the error other than to report it along with the condition that triggered the error to the supplier. In industry significant time is spent debugging code prior to delivery and maintaining code afterwards. Any concept or tool that aids in this function is indispensable to the project. Apparently many people understood this notion since for several years the proposal to broaden Java to include keyword support of programming by contract was purportedly the most frequent "non-bug" report requested by Java developers.
The book is well organized providing a set of step by step instructions on how to write robust contracts applicable to a wide range of examples from simple data structures to more advanced cases such as the implementation of the Observer Pattern. I considered myself well versed in design by contract but the six principles and guidelines as well as the frame rules, introduced successively via examples, provided a more rigorous approach to developing contracts than I had employed in the past.
In Chapter 2, the distinction between basic and derived queries is discussed and all six principles are introduced through a stack example. Each principle is unveiled in conjunction with designing methods and their contracts for the data structure.
In the development of the dictionary class in Chapter 3, the authors present a case for a new query which asks if the dictionary already contains a specific key. The query arises from the specific application of the principles pertaining to postconditions. This is an excellent example of how contracts result in the development of new and needed features in a class.
In Chapter 6, the authors present a clear rational for weakening inherited preconditions and strengthening postconditions and invariants in accordance with other literature pertaining to the same topic. In particular, the example of a delivery service reads like a case of retail agreement in plain language but is complemented by examples of code and UML diagrams. The concept of guarding postconditions with preconditions to facilitate possible redefinition of methods is also introduced and well explained.
Chapter 8 covers the benefits of design by contract and if the reader has compiled and executed the examples presented in the book, they will have experienced some of these benefits firsthand. Of course there are considerations like better documentation and more reliable code, but the debugging assistance is the most overt benefit of contracts. The stack traces associated with assertion exceptions are an invaluable tool during both development and maintenance. Anyone who has developed quality software under a tight schedule understands the benefits of precision bug identification and resolution.
Analysis by contract, introduced in the final chapter, presents the concepts of design by contract abstractly removed from the code specifics. The authors present an analysis of a person withdrawing money from a bank. In doing so they codify the sequence of events based on the contract stating that the design is "derived from the specification rather than being a design that is also being used as a specification." The obvious implication of this is that the final product will likely fulfill the specification implicitly.
This is a book packed with knowledge that is essential for all developers regardless of the current support of design by contract in conventional languages. In the future, as the more popular languages incorporate additional design by contract concepts, there will be an increased number of authors producing texts on these topics as well as a growing number of developers annotating their resumes accordingly. I suspect that all of these texts will reference Design by Contract by Example and many of the developers that already understand the concept will be well acquainted with the pages of this book.