Design by Contract, by Example
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 Examplepaves 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 commandsSeparate basic queries from derived queriesWrite a postcondition for each derived query that specifies what result can be returnedWrite a postcondition for each command that specifies the value of every basic queryDecide on a suitable precondition for every query and commandWrite invariants to define unchanging properties of objectsContracts 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 Exampleis 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