CSC 480 Software Engineering Design by Contract. Detail Design Road Map Begin with architectural models  Class model: domain classes  Overall state.

Slides:



Advertisements
Similar presentations
Design by Contract.
Advertisements

Practice Session 5 Java: Packages Collection Classes Iterators Generics Design by Contract Test Driven Development JUnit.
1 Computer Science 340 Software Design & Testing Inheritance & Design By Contract.
Chapter 7 Testing Class Hierarchies. SWE 415 Chapter 7 2 Reading Assignment  John McGregor and David A. Sykes, A Practical Guide to Testing Object-Oriented.
Software Engineering and Design Principles Chapter 1.
Copyright W. Howden1 Lecture 13: Programming by Contract.
Software Testing and Quality Assurance
1 Software Testing and Quality Assurance Lecture 28 – Testing Class Hierarchies.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
November 13, 2006ECEN 5543 / CSCI 5548 – Testing OO University of Colorado, Boulder 1 Testing Object-Oriented Software Principles Summary ECEN 5543 / CSCI.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
Software Requirements
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.
Feb. 23, 2004CS WPI1 CS 509 Design of Software Systems Lecture #5 Monday, Feb. 23, 2004.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 6: Object Creation.
1 Introduction to: Design by Contract Fall 2005 OOPD John Anthony.
Chapter 10 Class and Method Design
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION.
Subclasses and Subtypes CMPS Subclasses and Subtypes A class is a subclass if it has been built using inheritance. ▫ It says nothing about the meaning.
Ranga Rodrigo. Class is central to object oriented programming.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 10: Class and Method.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Specifying Interfaces.
CompSci 105 SS 2005 Principles of Computer Science Lecture 4 Lecturer: Santokh Singh.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Low-Level Detailed Design SAD (Soft Arch Design) Mid-level Detailed Design Low-Level Detailed Design Design Finalization Design Document.
More About Classes Ranga Rodrigo. Information hiding. Copying objects.
Two Parts of Every ADT An abstract data type (ADT)  is a type for encapsulating related data  is abstract in the sense that it hides distracting implementation.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
9-1 © Prentice Hall, 2007 Chapter 9: Analysis Classes Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey.
Lecture 6: Structural Modeling
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 10: Class and Method.
Deriving Operational Software Specification from System Goals Xin Bai EEL 5881 Course Fall, 2003.
What is Object-Oriented?  Organization of software as a collection of discreet objects that incorporate both data structure and behavior.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Protocols Software Engineering II Wirfs Brock et al, Designing Object-Oriented Software, Prentice Hall, Mitchell, R., and McKim, Design by Contract,
MDA & RM-ODP. Why? Warehouses, factories, and supply chains are examples of distributed systems that can be thought of in terms of objects They are all.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
7-1 © Prentice Hall, 2007 Topic 7: Analysis Classes Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 15. Review Interaction-Oriented Software Architectures – MVC.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Refining the Use Cases 1. How Use Cases Evolve  Early efforts typically define most of the major use cases.  The refining stages complete the process.
Class Diagrams. Terms and Concepts A class diagram is a diagram that shows a set of classes, interfaces, and collaborations and their relationships.
CEN th Lecture Advance Software Engineering (CEN-5011) Instructor: Masoud Sadjadi Object Design: Specifying.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc. All rights.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 5th Edition Copyright © 2015 John Wiley & Sons, Inc. All rights.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
CSC 520 – Advanced Object Oriented Programming, Fall, 2010 Thursday, September 30 Week 5, Generics and Inheritance Techniques, Meyer Ch. 10 & 16.
Principles of Programming & Software Engineering
Analysis Classes Unit 5.
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
State-Space and Behavior
Arab Open University 2nd Semester, M301 Unit 5
Software Design and Architecture
About the Presentations
TIM 58 Chapter 8: Class and Method Design
Computer Programming.
CSC 480 Software Engineering
Chapter 20 Object-Oriented Analysis and Design
Design Tips.
ISpec: A Compositional Approach to Interface Specification
Software Development Process Using UML Recap
Systems Analysis and Design with UML Version 2.0, Second Edition
Generics, Lambdas and Reflection
Presentation transcript:

CSC 480 Software Engineering Design by Contract

Detail Design Road Map Begin with architectural models  Class model: domain classes  Overall state model  Use case model Refine classes, make consistent, ensure complete Specify class invariants, if any Specify methods with  Pre- and post-conditions  Flowcharts and pseudocode Sketch unit test plans

Design by Contract Design by contract is about adding assertions to o-o programs  Used mostly at design and coding stages  Concepts are applicable to other stages as well Assertions are fact about a program that must be true for the program to be bug-free  Pre- and post-conditions  Invariants

Principles of Design by Contract Principle I - Separate queries from commands. Queries return a result but do not change the visible properties of the object. Commands might change the object but do not return a result. Principle 2 - Separate basic queries from derived queries. Derived queries can be specified in terms of basic queries. Principle 3 - For each derived query, write a post- condition that specifies what result will be returned, in terms of one or more basic queries. Then, if we know the values of the basic queries, we also know the values of the derived queries.

Principles (cont’d) Principle 4 - For each command, write a post-condition that specifies the value of every basic query. Now we know the total visible effect of each command. Principle 5 - For every query and command, decide on a suitable precondition. Preconditions constrain when c may call the queries and commands. Principle 6 - Write invariants to define unchanging properties of objects. Concentrate on properties that help the reader build an appropriate conceptual model of the abstraction the class embodies.

A Sample Class – Queue

Application Guidelines Guideline I - Add physical constraints where appropriate. Typically, these will be constraints that variables should not be void. Guideline 2 - Make sure that queries used in preconditions are cheap to calculate. If necessary, add cheap-to-calculate derived queries whose post- conditions verify them against more expensive queries. Guideline 3 - Constrain attributes using an invariant. When a derived query is implemented as an attribute, it can be constrained to be consistent with other queries by an assertion in the class’s invariant section.

Application Guidelines (cont’d) Guideline 4 - To support redefinition of features, guard each post-condition clause with its corresponding precondition. This allows unforeseen redefinitions by those developing subclasses. Guideline 5 - Place constraints on desired changes and frame rules In separate classes. This allows developers more freedom to extend your classes.