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:
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.
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.
Product Details
Would you like to update product info or give feedback on images?
|
|
Share your thoughts with other customers:
|
||||||||||||||||||||||
|
Most Helpful Customer Reviews
13 of 13 people found the following review helpful:
5.0 out of 5 stars
The best tutorial on design by contract,
By Charles Ashbacher (Marion, Iowa United States) - See all my reviews (TOP 500 REVIEWER) (VINE VOICE) (HALL OF FAME REVIEWER)
This review is from: Design by Contract, by Example (Paperback)
Despite its' power, design by contract is an underutilized software development technique. That is most likely explained by the speed of software development and the time that would be required to learn it well enough to use it. Most developers either do not, or feel that they do not have the time to stop and learn how to use design by contract effectively. Well, the former group simply cannot be helped, as not even design by contract will extend the time in a day. However, for the latter group, this book is for you. Design by contract is not difficult to learn, as is demonstrated in this book. The examples are very easy to understand and are chosen for their combination of ease of use as well as having applicability to the kinds of programs that developers create. While Eiffel and Java are used to create the examples, it is not critical that you know them to understand the code. The only requirement is that you understand the basic principles of object-oriented programming. While some background in logic would be helpful, all that is needed is what is required for writing correct Boolean expressions in programs. I am a big proponent of the design by contract model of software development. The writing of the contract principles forces a level of intellectual rigor that can dramatically improve the quality of your software. In this book, you can not only learn how to do it, but you will also learn how to do it well and the ways in which you can do it wrong. I have placed it in my list of the top ten books of the year.
11 of 12 people found the following review helpful:
2.0 out of 5 stars
Not enough material,
This review is from: Design by Contract, by Example (Paperback)
The aim of the book is to teach readers about contracts and how to write good ones. The main points are summarized at the start of the book in a series of six guidelines (as described in the review above):
- 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 This part is well written and provides good advice for people new to writing contracts. The presentation is however very academic with examples based on stacks and dictionaries. The authors then try to present more realistic examples. Unfortunately that's where they fail badly. The first example shows how to use contracts to write an observer pattern. The only thing that the authors show is that you can write a contract that makes sure that the observers are properly added to the list of observers. Since most modern languages implement the observer pattern in the language itself (via events), this is a contract that no-one needs to write. The problem that usually happens in real programming is that the events are wired up too early or too late. Contracts provide little help for this. The authors should have chosen an example that better demonstrates the power of contracts. The second example is an over-extended explanation about how you can write code so that you never call a method when its precondition is false. The explanation is convoluted and offers no real insight into programming by contracts. The final chapter discusses applying contracts to languages that do not support them natively (basically all languages other than Eiffel). I had high hopes for this chapter. Unfortunately, the authors recommend using a pre-processor (e.g., iContracts) or only implementing preconditions with assertions. Most programmers with a little experience will already be using assertions and will not learn much from the chapter. The book is a compilation of various papers that the authors published in conferences (mainly TOOLS). The problem is that the material is suited to a 20 page paper not a 200+ page book. Even with repetitions and ample space the lack of useful information is apparent. The second half of the book is a waste of paper. Contracts are a very useful tool when properly applied. The guidelines presented at the start of the book are very good. Unfortunately the book is marred by a lack of real world examples.
7 of 7 people found the following review helpful:
4.0 out of 5 stars
Clear and to the Point,
By John Childs (Granby, CT USA) - See all my reviews
This review is from: Design by Contract, by Example (Paperback)
This is surely the definitive work on contracts and assertions. The title says it all, as the book makes effective use of examples to illustrate this important topic. Before I read "Design by Contract by Example" I had not a clue as to how to write assertions. Mitchell and McKim's Six Principles simplified this subject such that I was able to write a fairly reasonable contract for a small system on my first try. This work demystifies the subject.
Share your thoughts with other customers: Create your own review
|
|
Tags Customers Associate with This Product(What's this?)Click on a tag to find related items, discussions, and people.
|
|
This product's forum
Active discussions in related forums
Search Customer Discussions
|
Related forums
|