Chapter 2 Comments, Conditions, Assertions Comments Preconditions Postconditions Assertions.

Slides:



Advertisements
Similar presentations
An Introduction to Programming and Object Oriented Design using Java 2 nd Edition. May 2004 Jaime Niño Frederick Hosch Chapter 5 : Programming By Contract.
Advertisements

Carlos D. Rivera February 28, 2007 Design-by-Contract.
©G. Millbery 2003Data, Information, Knowledge and Processing Slide 1 Validation  Making sure that the data value entered is sensible and reasonable 
Code Documentation. Important!  It’s for you  It’s for others.
The Fundamental Rule for Testing Methods Every method should be tested in a program in which every other method in the testing program has already been.
Chapter 1. The Phases of Software Development. Data Structure 2 Chapter outline  Objectives  Use Javadoc to write a method’s complete specification.
ISBN Chapter 3 Describing Syntax and Semantics.
Copyright © 2006 Addison-Wesley. All rights reserved. 3.5 Dynamic Semantics Meanings of expressions, statements, and program units Static semantics – type.
1 Design by Contract Building Reliable Software. 2 Software Correctness Correctness is a relative notion  A program is correct with respect to its specification.
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
Chapter 8 Designing Classes. Assignment Chapter 9 Review Exercises (Written)  R8.1 – 8.3, 8.5 – 8.7, 8. 10, 8.11, 8.13, 8.15, 8.19, 8.20 Due Friday,
Software Testing and Quality Assurance
Axiomatic Semantics Dr. M Al-Mulhem ICS
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing 2.
 An important topic: preconditions and postconditions.  They are a method of specifying what a function accomplishes. Preconditions and Postconditions.
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 8: Classes and Objects.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Axiomatic Semantics ICS 535.
Chair of Software Engineering Automatic Verification of Computer Programs.
Describing Syntax and Semantics
MCA –Software Engineering Kantipur City College. Topics include  Formal Methods Concept  Formal Specification Language Test plan creation Test-case.
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.
An Introduction to Programming and Object Oriented Design using Java 2 nd Edition. May 2004 Jaime Niño Frederick Hosch Chapter 5 : Programming By Contract.
Computer Science 340 Software Design & Testing Design By Contract.
© 2007 Lawrenceville Press Slide 1 Chapter 7 Top-Down Development  Problem-solving approach  Breaking a task down into smaller subtasks  First level.
CS 241 – Computer Programming II Lab Kalpa Gunaratna –
Pre/Post Condition Logic 03/06/2013. Agenda Hoare’s Logic Overview Application to Pre/Post Conditions.
Acceptance Testing Senior Design Fall 2013
CS Fall 2007 Dr. Barbara Boucher Owens. CS 2 Text –Main, Michael. Data Structures & Other Objects in Java Third Edition Objectives –Master building.
Contract based programming Using pre- and post-conditions, and object invariants Contract based programming1.
CS 261 – Data Structures Preconditions, Postconditions & Assert.
Programming Logic and Design Sixth Edition Chapter 5 Looping.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
P An important topic: preconditions and postconditions. p They are a method of specifying what a function accomplishes. Illinois State University Department.
October 2004J. B. Wordsworth J4ISDSPE1 Information Systems Development Specification.
ISBN Chapter 3 Describing Semantics.
Chapter 3 Part II Describing Syntax and Semantics.
Chapter 5 Selection Statements Mr. Dave Clausen La Cañada High School.
DOMAIN AND RANGE.
Test Driven Development Ben Hoskins. Test Driven Development.
L13: Design by Contract Definition Reliability Correctness Pre- and post-condition Asserts and Exceptions Weak & Strong Conditions Class invariants Conditions.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 6 Functions.
SWE 4743 Abstract Data Types Richard Gesick. SWE Abstract Data Types Object-oriented design is based on the theory of abstract data types Domain.
Defensive Programming CNS 3370 Copyright 2003, Fresh Sources, Inc.
1 Introduction 1. Why Data Structures? 2. What AreData Structure? 3. Phases of Software Development 4. Precondition and Postcondition 5. Examples.
Chapter 7 Programming by contract: preconditions and postconditions.
“Discipline is the refining fire by which talent becomes ability.” – Roy L. Smith Thought for the Day.
Loop Invariants and Binary Search Chapter 4.4, 5.1.
Defining Classes I Part B. Information hiding & encapsulation separate how to use the class from the implementation details separate how to use the class.
Chapter 1 The Phases of Software Development. Software Development Phases ● Specification of the task ● Design of a solution ● Implementation of solution.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
CORRECTNESS ISSUES AND LOOP INVARIANTS Lecture 8 CS2110 – Fall 2014.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 17 – Specifications, error checking & assert.
11/22/2016IT 3271 A formal system:Axioms and Rules, for inferring valid specification x := m; y := n; while ¬(x=y) do if x>y then x := x-y else y := y-x.
Class Invariants Class invariants are logical conditions to ensure the correct working of a class. Class invariants must hold true when an object is created,
Chapter 07 – Rate, Ratio & Variation Q1
Chapter 6 CS 3370 – C++ Functions.
Pre-Algebra Chapter 5 Review
Chapter 6: Modular Programming
CSE 374 Programming Concepts & Tools
Requirements: Use Case Models and Narratives
Chapter 6 Sub Procedures
Using Free Functions Chapter 3 Computing Fundamentals with C++
Programming Languages 2nd edition Tucker and Noonan
Design by contract Object-Oriented Software Construction by Bertrand Meyer, Prentice Hall The presence of a precondition or postcondition in a routine.
Design by contract Object-Oriented Software Construction by Bertrand Meyer, Prentice Hall The presence of a precondition or postcondition in a routine.
CSE 1020:Software Development
Programming Languages 2nd edition Tucker and Noonan
Chapter 5 Selection Statements
Unit Testing.
Presentation transcript:

Chapter 2 Comments, Conditions, Assertions Comments Preconditions Postconditions Assertions

Preconditions Conditions under which a method may be called and expected to produce correct results Tip: –use to check arguments passed to method to guarantee that they do have valid values Examples – (y!=0), (link==null), (x>=y)

Postconditions State of the program once the routine has been completed Postconditions should be correct only if Preconditions were met Tip: –Test if computed values fall within acceptable ranges Examples – (x!=0), (link!=null), (x<=y)

How to Implement Pre- and Post-Conditions: Assertions Assumption made about the state of the program Assert.pre(boolean test, String message) Assert.post(boolean test, String message) Assert.condition(boolean test, String message) Assert.fail(String message)

Example

Assignment #2 Problems: Due: