92.3913Jan 2005 Ron McFadyen1 Contracts Used to help understand requirements more completely (and so may not always be necessary) based on assertions;

Slides:



Advertisements
Similar presentations
Design by Contract.
Advertisements

Building Bug-Free O-O Software: An Introduction to Design By Contract A presentation about Design By Contract and the Eiffel software development tool.
Carlos D. Rivera February 28, 2007 Design-by-Contract.
Object Design Examples with GRASP
1 Design by Contract Building Reliable Software. 2 Software Correctness Correctness is a relative notion  A program is correct with respect to its specification.
Feb 2003 R McFadyen1 Contracts (Ch 13) Used to help understand requirements more completely based on assertions; assertions are applicable to any.
Jan 23, Ron McFadyen1 SSD for a samplePOS Use Case Figure 13.1 Input Events invoke a system operation of the same name same idea as in object-oriented.
Object-Oriented Analysis and Design
Software Testing and Quality Assurance: The Testing Perspective Reading Assignment: –John McGregor and David A. Sykes, A Practical Guide to Testing Object-Oriented.
Software Testing and Quality Assurance
Static and Dynamic Contract Verifiers For Java Hongming Liu.
NJIT Use Case Model Operation Contracts Prepared By: Sumit Sharma.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
ACS-3913Fall 2009 Ron McFadyen1 Contracts Used to help understand requirements more completely (and so may not always be necessary) based on assertions;
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
September 2002 R McFadyen1 Domain Model Use Case Model text diagram SSD System operation contracts Design Model Figure 13.3.
Eiffel Language and Design by Contract Contract –An agreement between the client and the supplier Characteristics –Expects some benefits and is prepared.
Sept Ron McFadyen1 Extend Relationship.
1 © Wolfgang Pelz Design by Contract Design by Contract™ Based on material drawn from: Bertrand.
Use Case Model Operation Contracts Prepared By: Sumit Sharma and Sravanthi Gillala.
חוזים – Contracts 1. Larman – Chapter 10 – SSDs 10.2 What are System Sequence Diagrams? (introduction) Use cases describe how external actors interact.
Object-Oriented Analysis and Design
Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative Development Part III Elaboration Iteration I – Basic1.
Computer Science 340 Software Design & Testing Design By Contract.
Ranga Rodrigo. Class is central to object oriented programming.
CSSE 374: Operations Contracts and Logical Architectures Steve Chenoweth Office: Moench Room F220 Phone: (812)
Lecture 16 March 22, 2011 Formal Methods CS 315 Spring Adapted from slides provided by Jason Hallstrom and Murali Sitaraman (Clemson)
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Specifying Interfaces.
Object Oriented Analysis and Design System Events & Contracts.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Chapter 6 Use Cases. Use Cases: –Text stories Some “actor” using system to achieve a goal –Used to discover and record requirements –Serve as input to.
Use Case Model Operation Contracts Chapter 11 Applying UML and Patterns Craig Larman.
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Review ♦ System sequence diagram ♦ Domain model
1 Lecture 6: Operation Contracts. 2 Overview  What is contract ?  The guidelines for writing contracts for the system operations.  Use Case realizations.
Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11.
Larman ch. 131 Use-Case Model : Adding Detail with operation contracts Larman ch. 13.
System sequence diagrams
Chapter 11 Operation Contracts. What They Are An operation is a specification of a transformation or query that an object may be called on to execute.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
Operation Contracts. Primary way to describe system behavior is with use cases Operation contracts provide more details in terms of state changes to objects.
Week 4 Operational Contracts Requirements to Design Logical Architecture.
TK2023 Object-Oriented Software Engineering CHAPTER 12 Introduction to Responsibility-Driven Design.
1 Devon M. Simmonds, Computer Science Department Design by Contract Devon M. Simmonds Computer Science Department University of North Carolina, Wilmington.
Class Design I Class Contracts Readings: 2 nd Ed: Section 9.5, Advanced Topic nd Ed: Section 8.5, Advanced Topic 8.2 Some ideas come from: “Practical.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
L13: Design by Contract Definition Reliability Correctness Pre- and post-condition Asserts and Exceptions Weak & Strong Conditions Class invariants Conditions.
Domain Model A representation of real-world conceptual classes in a problem domain. The core of object-oriented analysis They are NOT software objects.
SWE 4743 Abstract Data Types Richard Gesick. SWE Abstract Data Types Object-oriented design is based on the theory of abstract data types Domain.
1 Chapter 9: Operation Contracts Chapter 13 in Applying UML and Patterns Book.
AP Java Ch. 4 Review Question 1  Java methods can return only primitive types (int, double, boolean, etc).
DBC NOTES. Design By Contract l A contract carries mutual obligations and benefits. l The client should only call a routine when the routine’s pre-condition.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
Use-Case Model: Adding Detail with Operation Contracts.
1 Design Model Use-Case realizations with GRASP Larman chapter 17.
Design by Contract. The Goal Ensure the correctness of our software (correctness) Recover when it is not correct anyway (robustness) Correctness: Assertions.
1 Object Oriented Analysis and Design System Events & Contracts.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
OO Methodology Elaboration Phase Iteration 1- Part 2.
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
System Sequence Diagrams and Operation Contracts
Used to help understand requirements more completely
System sequence diagrams
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
Computer Science 340 Software Design & Testing
Operation Contracts Ch. 11.
Formal Methods Lecture 16 March 22, 2011 CS 315 Spring 2011
Presentation transcript:

Jan 2005 Ron McFadyen1 Contracts Used to help understand requirements more completely (and so may not always be necessary) based on assertions; assertions are applicable to any element of the UML text discusses contracts for system operations; contracts are applicable to execution of any software component

Jan 2005 Ron McFadyen2 Domain Model Use Case Model text diagram SSD System operation contracts Design Model

Jan 2005 Ron McFadyen3 Contracts A contract is a technique for describing system operations in terms of state changes to objects in a Domain Model Contracts are based on work by Bertrand Meyer … Eiffel programming language and the concept of assertion a statement, a constraint or declaration, that must be true a false value indicates a bug

Jan 2005 Ron McFadyen4 Constraints Three types pre-condition: must be true before a part of the system executes post-condition: must be true after a part of the system executes invariant: must be true before and after any part of the system is executed.

Jan 2005 Ron McFadyen5 Consider the execution of a routine: The called routine provides a service - it is the supplier The caller is the client requesting the service. A contract will spells out precisely the obligations of the caller (client) and the callee (supplier). The contract serves as an interface specification for the routine. Example: consider a routine that merges two sorted sequences. The merge routine is the supplier of the service; the calling routine is the caller. A contract will spell out the responsibilities of each party. Contracts

Jan 2005 Ron McFadyen6 Client: Ensure that the both sequences to be merged are each already sorted Supplier: Efficiently merge the two sorted sequences into one sorted sequence Contracts Software contract: The responsibilities of the client will be called pre- conditions The responsibilities of the supplier will be called post- conditions

Jan 2005 Ron McFadyen7 Pre-condition: both sequences to be merged are each already sorted Post-condition: the two sorted sequences are merged into one sorted sequence Contracts

Jan 2005 Ron McFadyen8 Contracts Contract Components (Larman) Operation - name and parameters Cross References – where (use cases) operation used Preconditions – noteworthy assumptions about the state of the system or Domain Model objects Postconditions - state of objects after the operation completes objects:any new ones? any attributes modified? associations: any new or modified associations? Larman’s version is very informal

Jan 2005 Ron McFadyen9 SSD for a samplePOS Use Case Input Events invoke a system operation of the same name same idea as in object-oriented programming when we say a message foo invokes the method foo Referred to (correctly) as the enterItem system operation in 3 rd edition

Jan 2005 Ron McFadyen10 SalesLineItem quantity Product Specification itemID Sale 1 1..* * 1Described by Contained in The part of the Domain Model relevant to enterItem( ) – discussed in a later chapter

Jan 2005 Ron McFadyen11 Contracts Example Operation:enterItem (itemID : ItemID, quantity : integer) Preconditions there is a Sale underway Postconditions a SalesLineItem instance was created an association between the sale and the sales line item was created an attribute, quantity, was modified an association between the product specification and the sales line item was created

Jan 2005 Ron McFadyen12 Design By Contract (DBC) provides the basis for documenting software interfaces Reusers of a software component need to understand what the software provides them and what they must do to obtain these benefits. This is the contract. DBC is perhaps a best non-practice. Example of a new DBC tool: iContract: Design by Contract in Java allows one to include runtime assertions for development purposes and suppress them for production cooltools.html Aside