DOC PREVIEW
Toronto ECE 450 - Lecture 9 / Tutorial 8 - Software Contracts

This preview shows page 1-2-3 out of 10 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Spring 2005 ECE450H1S Software Engineering IILecture 9 / Tutorial 8Software ContractsDesign by contractsProgramming by contractsSpring 2005 ECE450H1S Software Engineering II1. Sign a contract2. Design by contract3. Programming by contract4. Summary5. Questions and AnswersToday…Spring 2005 ECE450H1S Software Engineering IIHaving done one module, to swap with other team, you can sign a contract with other teams:• Name of Team A: …………………….• Name of Team B: …………………….• Team A is responsible for the ……………. module• Team B is responsible for the ……………. module• Terms on functionalities and qualities• Terms on intellectual properties: license• Terms on compensation for failures• And so on …• Signature1. Sign a ContractSpring 2005 ECE450H1S Software Engineering II• Why design contracts? Verification and Validation________ checks whether the end-product meets the customer requirements________ check whether the product of current phase preserves the requirements of the product of the previous phase• In object-oriented software construction, a design contract consists of such obligations– Pre-conditions and post-condition for a _________– Invariants for a ________• Inheritance can extend the design contracts – precondition of A.foo() implies precondition of B.foo() _______ extends _______– postcondition of C.bar() implies postcondition of D.bar()_______ extends _______– invariant of E implies invariant of F_______ extends _______ReferenceBertrand Meyer. “Object-oriented software construction”. Prentice Hall, 1997.2. Design by contractsSpring 2005 ECE450H1S Software Engineering II3. Programming by contractsHow to guarantee the design contracts?Today we show three techniques:• Assertions• Unit tests• Class wrappersSpring 2005 ECE450H1S Software Engineering II3.1 Assertions• Assertions are debug statements inserted into the normal statements to check on the conditionsfloat division(float a, float b) {assert(______);float c;// c = f(a, b) assert(______);return c;}class number {int n;// invariant: n>0void inc() { assert(_____)... assert(_____); }void dec() { assert(_____)... assert(_____);};}• Assertions can be ____________ before the code is releasedSpring 2005 ECE450H1S Software Engineering II3.2 Unit tests• One can guarantee the correctness through unit tests, for example:– junit.framework.Assert.assertTrue("output matches input", nodiff);– junit.framework.Assert.assertEquals("output matches input", output, expected_output);– junit.framework.Assert.assertNotNull("output matches input", object);– And so onSpring 2005 ECE450H1S Software Engineering II3.3 Class wrappers• Having a class wrapper is more convenient• Exampleclass Number {NumberImpl n;float division (float a, float b) {assert(b!=0);float c = n.division(a, b);assert(c*a == b);return c; } }• Question: The ________ design pattern is used in the above example• Advantages over assertions and unit tests– Better than assertions: _______________________________– Better than unit tests: _______________________________________________________________________• Reference• http://www.ddj.com/documents/s=1640/ddj0503f/Spring 2005 ECE450H1S Software Engineering II4. Summary• What is “design by contracts”• How to implement the contracts• Think about how to enforce your customer contracts with your developer contracts?• Questions and answers…Spring 2005 ECE450H1S Software Engineering IIProject informationOn Web Service Deployment• What’s more– We have a course forumhttp://seawolf.cdf.toronto.edu:9192/ece450• If you want to deploy the web service in the lab– We have a Tomcat/MySQL server in the Linux Lab of CDF– Production http://werewolf.cdf.toronto.edu:9192/production– Sand box: http://werewolf.cdf.toronto.edu:9192/sandbox– Put your binary files into• /u/yijun/.ece450/production• /u/yijun/.ece450/sandbox– Ask me to create a mysql database for you if


View Full Document
Download Lecture 9 / Tutorial 8 - Software Contracts
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 9 / Tutorial 8 - Software Contracts and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 9 / Tutorial 8 - Software Contracts 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?