Component-Based Software Engineering Components and Interfaces Paul Krause.

Slides:



Advertisements
Similar presentations
Copyright W. Howden1 Programming by Contract CSE 111 6/4/2014.
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.
Karlstad University Computer Science Design Contracts and Error Management Design Contracts and Errors A Software Development Strategy Eivind J. Nordby.
1 Computer Science 340 Software Design & Testing Inheritance & Design By Contract.
Design by Contract. Design by contract is the process of developing software based on the notion of contracts between objects, which are expressed as.
1 Design by Contract Building Reliable Software. 2 Software Correctness Correctness is a relative notion  A program is correct with respect to its specification.
Weakest pre-conditions and towards machine consistency Saima Zareen.
Basic Concepts in Component-Based Software Engineering
Software Engineering and Design Principles Chapter 1.
On the Relation between Design Contracts and Errors Karlstad University Computer Science On the Relation Between Design Contracts and Errors A Software.
Object-Oriented Programming with Java The Java Event Model Lecture 5.
Copyright W. Howden1 Lecture 13: Programming by Contract.
Software Testing and Quality Assurance
Static and Dynamic Contract Verifiers For Java Hongming Liu.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session 6 7 October 2008.
Karlstad University Computer Science Design Contracts and Error Management Design Contracts and Errors A Software Development Strategy (anpassad för PUMA)
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
Object-Oriented Programming with Java Lecture 2 The Java Event Model.
Describing Syntax and Semantics
Eiffel Language and Design by Contract Contract –An agreement between the client and the supplier Characteristics –Expects some benefits and is prepared.
1 © Wolfgang Pelz Design by Contract Design by Contract™ Based on material drawn from: Bertrand.
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.
Component-Based Software Engineering Components and Interfaces Paul Krause.
Ranga Rodrigo. Class is central to object oriented programming.
Computer Science School of Computing Clemson University Discrete Math and Reasoning about Software Correctness Murali Sitaraman
Procedure specifications CSE 331. Outline Satisfying a specification; substitutability Stronger and weaker specifications - Comparing by hand - Comparing.
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
Component-Based Software Engineering Using Interfaces Paul Krause.
Contract based programming Using pre- and post-conditions, and object invariants Contract based programming1.
Design by Contract in Java Concept and Comparison.
SWE 619 © Paul Ammann Procedural Abstraction and Design by Contract Paul Ammann Information & Software Engineering SWE 619 Software Construction cs.gmu.edu/~pammann/
Programming Principles Chapter 1. Objectives Discuss the program design process. Introduce the Game of Life. Discuss object oriented design. – Information.
© Paul Ammann, 2008 Design by Contract Paul Ammann CS/SWE 332.
Software Reliability. Risks of faulty software  Example: –Therak 25, –AT&T network failure –Airport traffic control  Costs of software errors can be.
1 Devon M. Simmonds, Computer Science Department Design by Contract Devon M. Simmonds Computer Science Department University of North Carolina, Wilmington.
Computer Science 209 Software Development Handing Errors and Creating Documentation.
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.
1 Assertions. 2 A boolean expression or predicate that evaluates to true or false in every state In a program they express constraints on the state that.
Karlstad University Computer Science Design Contracts and Error Management External and internal errors and their contracts.
Defensive Programming CNS 3370 Copyright 2003, Fresh Sources, Inc.
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.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
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.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
Interfaces CMSC 202. Public Interfaces Objects define their interaction with the outside world through the their public interface. A class' public interface.
Testing It is much better to have a plan when testing your programs than it is to just randomly try values in a haphazard fashion. Testing Strategies:
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Recursion,
Component-Based Software Engineering Components and Interfaces Paul Krause and Sotiris Moschoyiannis.
CMPE 280 Web UI Design and Development August 29 Class Meeting
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
Component Based Software Engineering
Software Development Handing Errors and Creating Documentation
OGSA Data Architecture Scenarios
Design by Contract Fall 2016 Version.
CSC 480 Software Engineering
Programming Languages 2nd edition Tucker and Noonan
Component-Based Software Engineering
IMPORTANT NOTE Some parts of these section slides deal with null ints. This was a mistake, as primitives cannot be null. These issues have been corrected.
Output Variables {true} S {i = j} i := j; or j := i;
Go to pollev.com/cse143.
Component-Based Software Engineering
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
CSE 1020:Software Development
Programming Languages 2nd edition Tucker and Noonan
Design Contracts and Errors A Software Development Strategy
Presentation transcript:

Component-Based Software Engineering Components and Interfaces Paul Krause

Lecture 6 - Interfaces Contents  Interfaces as Contracts  Future Proofing  Non-functional requirements  Are we done?

Components and Interfaces A B1B2 A requires certain functionality to fulfil its obligations. B1 and/or B2 provide that functionality. An interface mediates between clients and providers.

Interfaces as contracts  Can view an interface specification as a “contract” between the client and a provider  So the interface specification must state: What the client needs to do What the client needs to do What a provider can rely on What a provider can rely on What a provider must promise in return What a provider must promise in return What the client can rely on What the client can rely on

Pre- and Post-Conditions  Pre-conditions: What the client must establish before calling the operation What the client must establish before calling the operation The provider can rely on this condition being true whenever the operation is called The provider can rely on this condition being true whenever the operation is called  Post-conditions: What the provider must establish before returning to the client What the provider must establish before returning to the client The client can rely on this condition being true whenever the call to the operation returns The client can rely on this condition being true whenever the call to the operation returns

Example public interface Directory { public void addEntry(String name, File file); // pre name != “” and file != null // post File file = map.get(name) } Associate pre- and post-conditions to every method in the interface

Lecture 6 - Interfaces Contents  Interfaces as Contracts  Future Proofing  Non-functional requirements  Are we done?

Future proofing  An interface acts as a contract between client and provider  Suppose an interface remains unchanged  Is there any scope for revising an implementation without introducing a risk of “breaking” old clients?  Ans: The revised implementation may require less and/or provide more

Future Proofing public interface Arithmetic { public double processNumbers(double x, double y); // pre x > 5 and y > 5 // post if r = this.processNumbers(x, y) then r > 10 } public double processNumbers(double x, double y) { if ((x < 0) || (y < 0)) throw new IllegalArgumentException(“Args must be >=0”); return x + y ; }

Future Proofing x > 5 and y > 5 implies x >=0 and y >= 0  The new implementation requires less than the interface  The implementation “weakens” the pre- conditions return >= 20 implies return > 10  The new implementation provides more than the interface specifies  The implementation “strengthens” the post- conditions

Lecture 6 - Interfaces Contents  Interfaces as Contracts  Future Proofing  Non-functional requirements  Are we done?

What else can go wrong? public interface Directory { public void addEntry(String name, File file); // pre name != “” and file != null // post File file = map.get(name) }  strictly this is only a guarantee of partial correctness  the operation either terminates correctly or does not terminate at all!  progress conditions:  something guaranteeing the pre-condition will lead to something guaranteeing the post-condition

Non-functional requirements  We have seen how respecting pre- and post- conditions reduces the risk of a revised implementation “breaking” a client  But are changes in the functional behaviour the only way an implementation can break a client?  Consider a Maths interface, with methods to support an animation package What about a new implementation that improves accuracy? What about a new implementation that improves accuracy?

Specifying the Service Level Now add guarantees for levels of:  Availability;  Mean time between failures;  Mean time to repair;  Throughput;  Data safety;  Capacity.

Time and Space Requirements  Specifying execution time is platform dependent  So what can realistically be included in a contract?  Could use complexity bounds E.g. perform an operation on n elements in n log n time, using at most log n additional storage cells E.g. perform an operation on n elements in n log n time, using at most log n additional storage cells  A client can then determine the absolute time and space bounds for a given provider on a given platform

Lecture 6 - Interfaces Contents  Interfaces as Contracts  Future Proofing  Non-functional requirements  Are we done?

Are we done?  Interfaces act as contracts between clients and providers  Suggest you think about: Pre-conditions Pre-conditions Post-conditions Post-conditions Leads-to conditions Leads-to conditions Non-functional requirements Non-functional requirements  As that it?

 Pauls Pictures  Pauls Documents  Pauls Sums  Pauls Homework No!  Pauls Pictures  Pauls Documents  Pauls Sums  Pauls Homework  Pauls ToDo Lists