Upload
zaria-pettinger
View
216
Download
0
Tags:
Embed Size (px)
Citation preview
Carlos D. RiveraFebruary 28, 2007
Design-by-ContractDesign-by-Contract
WHAT ?
Design-by-Contract (DBC) is a methodology for designing
computer software.
WHAT ?
Design-by-Contract (DBC) is a methodology for designing
computer software.
• Define checkable interface specifications
WHAT ?
Design-by-Contract (DBC) is a methodology for designing
computer software.
• Define checkable interface specifications
• Theory of abstract data types (e.g., interfaces)
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-)
HISTORY
Bertrand Meyer
HISTORY
Bertrand Meyer
• Eiffel
HISTORY
Bertrand Meyer
• Eiffel
• Object-Oriented Software Construction
HISTORY
Bertrand Meyer
• Eiffel
• Object-Oriented Software Construction
• DBC circa 1986
INTRODUCTION
Design-by-Contract is a thinly veiled mathematical proof.
FOUNDATIONDesign-by-Contract :
FOUNDATION
1. Abstract Mathematical Models of a System• “this phenomena can be represented by
this mathematical language”
Design-by-Contract :
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 :
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 :
OVERVIEW
Object-oriented process commonly implementedusing assertions.
OVERVIEW
Object-oriented process commonly implementedusing assertions.
Assertion benefits:
OVERVIEW
Object-oriented process commonly implementedusing assertions.
Assertion benefits:
• Program correctness/testing
OVERVIEW
Object-oriented process commonly implementedusing assertions.
Assertion benefits:
• Program correctness/testing
• On/off during development
WHY ?
Benefits of DBC :
WHY ?
1. Clear design process
Benefits of DBC :
WHY ?
1. Clear design process
2. Inheritance
Benefits of DBC :
WHY ?
1. Clear design process
2. Inheritance
3. Exception handling
Benefits of DBC :
WHY ?
1. Clear design process
2. Inheritance
3. Exception handling
4. Automatic software documentation
Benefits of DBC :
HOW ?
Client-Supplier business relationships.
HOW ?
Client-Supplier business relationships.
Basis: Pre-condition
If you have the right amount of money
If input values within specified range
Expectations
HOW ?
Basis: Post-condition
You will get this product
It will be transformed to this result
Guaranteed
Client-Supplier business relationships.
HOW ?
Basis: Class Invariant
Under these conditions
Object analysis invariant { assert ( ); }
Maintain
Client-Supplier business relationships.
CONCLUSION
Analogy :
CONCLUSION
Analogy :
Molds can be used to make copies of objects with negligible variation.
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.
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.
CONCLUSION
Most importantly, the documentation provided
by DBC creates a contract whereby
requirements can be specified and met
without avail.
CONCLUSION
Most importantly, the documentation provided
by DBC creates a contract whereby
requirements can be specified and met
without avail.
Questions, Concerns, Complaints ?