carlos d. rivera february 28, 2007 design-by-contract
TRANSCRIPT
![Page 1: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/1.jpg)
Carlos D. RiveraFebruary 28, 2007
Design-by-ContractDesign-by-Contract
![Page 2: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/2.jpg)
WHAT ?
Design-by-Contract (DBC) is a methodology for designing
computer software.
![Page 3: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/3.jpg)
WHAT ?
Design-by-Contract (DBC) is a methodology for designing
computer software.
• Define checkable interface specifications
![Page 4: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/4.jpg)
WHAT ?
Design-by-Contract (DBC) is a methodology for designing
computer software.
• Define checkable interface specifications
• Theory of abstract data types (e.g., interfaces)
![Page 5: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/5.jpg)
WHAT ?
Design-by-Contract (DBC) is a methodology for designing
computer software.
• Define checkable interface specifications
• Theory of abstract data types (e.g., interfaces)
• Metaphor of business contract (e.g., pre-, post-)
![Page 6: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/6.jpg)
HISTORY
Bertrand Meyer
![Page 7: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/7.jpg)
HISTORY
Bertrand Meyer
• Eiffel
![Page 8: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/8.jpg)
HISTORY
Bertrand Meyer
• Eiffel
• Object-Oriented Software Construction
![Page 9: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/9.jpg)
HISTORY
Bertrand Meyer
• Eiffel
• Object-Oriented Software Construction
• DBC circa 1986
![Page 10: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/10.jpg)
INTRODUCTION
Design-by-Contract is a thinly veiled mathematical proof.
![Page 11: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/11.jpg)
FOUNDATIONDesign-by-Contract :
![Page 12: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/12.jpg)
FOUNDATION
1. Abstract Mathematical Models of a System• “this phenomena can be represented by
this mathematical language”
Design-by-Contract :
![Page 13: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/13.jpg)
FOUNDATION
1. Abstract Mathematical Models of a System• “this phenomena can be represented by
this mathematical language”
2. Formal Specification• “this mathematical model will produce this, always”
Design-by-Contract :
![Page 14: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/14.jpg)
FOUNDATION
1. Abstract Mathematical Models of a System• “this phenomena can be represented by
this mathematical language”
2. Formal Specification• “this mathematical model will produce this, always”
3. Formal Verification• “we can check if the specification is true
for every case”
Design-by-Contract :
![Page 15: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/15.jpg)
OVERVIEW
Object-oriented process commonly implementedusing assertions.
![Page 16: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/16.jpg)
OVERVIEW
Object-oriented process commonly implementedusing assertions.
Assertion benefits:
![Page 17: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/17.jpg)
OVERVIEW
Object-oriented process commonly implementedusing assertions.
Assertion benefits:
• Program correctness/testing
![Page 18: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/18.jpg)
OVERVIEW
Object-oriented process commonly implementedusing assertions.
Assertion benefits:
• Program correctness/testing
• On/off during development
![Page 19: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/19.jpg)
WHY ?
Benefits of DBC :
![Page 20: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/20.jpg)
WHY ?
1. Clear design process
Benefits of DBC :
![Page 21: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/21.jpg)
WHY ?
1. Clear design process
2. Inheritance
Benefits of DBC :
![Page 22: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/22.jpg)
WHY ?
1. Clear design process
2. Inheritance
3. Exception handling
Benefits of DBC :
![Page 23: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/23.jpg)
WHY ?
1. Clear design process
2. Inheritance
3. Exception handling
4. Automatic software documentation
Benefits of DBC :
![Page 24: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/24.jpg)
HOW ?
Client-Supplier business relationships.
![Page 25: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/25.jpg)
HOW ?
Client-Supplier business relationships.
Basis: Pre-condition
If you have the right amount of money
If input values within specified range
Expectations
![Page 26: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/26.jpg)
HOW ?
Basis: Post-condition
You will get this product
It will be transformed to this result
Guaranteed
Client-Supplier business relationships.
![Page 27: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/27.jpg)
HOW ?
Basis: Class Invariant
Under these conditions
Object analysis invariant { assert ( ); }
Maintain
Client-Supplier business relationships.
![Page 28: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/28.jpg)
CONCLUSION
Analogy :
![Page 29: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/29.jpg)
CONCLUSION
Analogy :
Molds can be used to make copies of objects with negligible variation.
![Page 30: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/30.jpg)
CONCLUSION
Analogy :
Molds can be used to make copies of objects with negligible variation.
Assertions can be used to create validated clones of ADTs of precise definition.
![Page 31: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/31.jpg)
CONCLUSIONEven though Design-by-Contract may seem
straight-forward and almost routinely basic,
its importance lies in its power to create a
type of mutually agreed upon business
contract, equally understandable to both the
client and developer, that scientifically maps
a problem-solving mathematical model to the
client’s needs.
![Page 32: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/32.jpg)
CONCLUSION
Most importantly, the documentation provided
by DBC creates a contract whereby
requirements can be specified and met
without avail.
![Page 33: Carlos D. Rivera February 28, 2007 Design-by-Contract](https://reader033.vdocuments.site/reader033/viewer/2022051614/55183197550346a7318b5052/html5/thumbnails/33.jpg)
CONCLUSION
Most importantly, the documentation provided
by DBC creates a contract whereby
requirements can be specified and met
without avail.
Questions, Concerns, Complaints ?