Component-Based Software Engineering Components and Interfaces Paul Krause and Sotiris Moschoyiannis.

Slides:



Advertisements
Similar presentations
Copyright W. Howden1 Programming by Contract CSE 111 6/4/2014.
Advertisements

Karlstad University Computer Science Design Contracts and Error Management Design Contracts and Errors A Software Development Strategy Eivind J. Nordby.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Design by Contract. Design by contract is the process of developing software based on the notion of contracts between objects, which are expressed as.
Functions ROBERT REAVES. Functions  Interface – the formal description of what a subprogram does and how we communicate with it  Encapsulation – Hiding.
ISBN Chapter 3 Describing Syntax and Semantics.
1 Design by Contract Building Reliable Software. 2 Software Correctness Correctness is a relative notion  A program is correct with respect to its specification.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
Feb 2003 R McFadyen1 Contracts (Ch 13) Used to help understand requirements more completely based on assertions; assertions are applicable to any.
Basic Concepts in Component-Based Software Engineering
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
Software Engineering and Design Principles Chapter 1.
Component-Based Software Engineering Components and Interfaces Paul Krause.
Object-Oriented Programming with Java The Java Event Model Lecture 5.
Software Testing and Quality Assurance
Page 1 Building Reliable Component-based Systems Chapter 2 -Specification of Software Components Chapter 2 Specification of Software Components.
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.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Object-Oriented Programming with Java Lecture 2 The Java Event Model.
Components, interfaces, and re-entrance Taciana Amorim Vanderlei
Describing Syntax and Semantics
Component-Based Software Engineering CSM-15 Paul Krause.
Computer Science 340 Software Design & Testing Design By Contract.
Component-Based Software Engineering Components and Interfaces Paul Krause.
A Survey of Software Refactoring Tom Mens, Tom Tourwé
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.
Software Models (Cont.) 9/22/2015ICS 413 – Software Engineering1 -Component-based software engineering -Formal Development Model.
Reading and Writing Mathematical Proofs
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
SWE 619 © Paul Ammann Procedural Abstraction and Design by Contract Paul Ammann Information & Software Engineering SWE 619 Software Construction cs.gmu.edu/~pammann/
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Composition of UML Described Refactoring Rules Presented by Chin-Yi Tsai.
An Ontological Framework for Web Service Processes By Claus Pahl and Ronan Barrett.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
© Paul Ammann, 2008 Design by Contract Paul Ammann CS/SWE 332.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Requirement Engineering Virtusa Training Group 2004 Trainer: Ojitha Kumanayaka Duration : 1 hour.
Architecture View Models A model is a complete, simplified description of a system from a particular perspective or viewpoint. There is no single view.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
1 Devon M. Simmonds, Computer Science Department Design by Contract Devon M. Simmonds Computer Science Department University of North Carolina, Wilmington.
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.
SWE 4743 Abstract Data Types Richard Gesick. SWE Abstract Data Types Object-oriented design is based on the theory of abstract data types Domain.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 15. Review Interaction-Oriented Software Architectures – MVC.
Introduction to business component technologies. Component definitions Szyperski: A software component is a unit of composition with contractually specified.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
Basic Concepts and Definitions
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.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
EECE 310: Software Engineering
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
Distribution and components
Design by Contract Fall 2016 Version.
Specifying Object Interfaces
Programming Languages 2nd edition Tucker and Noonan
An Introduction to Software Architecture
Baisc Of Software Testing
ISpec: A Compositional Approach to Interface Specification
Component-Based Software Engineering
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
Computer Science 340 Software Design & Testing
Programming Languages 2nd edition Tucker and Noonan
COMPONENT – BASED SOFTWARE ENGINEERING MODULE 2 – SECOND SEMESTER MKHIZE, BSC HONS COMPUTER SCIENCES, DIP IT, ICDL.
Formal Methods Lecture 16 March 22, 2011 CS 315 Spring 2011
Design Contracts and Errors A Software Development Strategy
Presentation transcript:

Component-Based Software Engineering Components and Interfaces Paul Krause and Sotiris Moschoyiannis

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

Revised Definition  A software component is a unit of composition with contractually specified interfaces and explicit context dependencies only  A software component can be deployed independently and is subject to composition by third parties 1996 European Conference on Object-Oriented Programming

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

Components in UML 2.0 > A B IName1 IName2 IName3 IName4 Component A provides IName1 & IName2 Component A requires IName3 Component B provides IName3 Component B requires IName4 Components A and B are composed on the basis of interfaces provided by one and required by the other (i.e. interface IName3) > A

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

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

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

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  Is that it?

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

Describing contracts  An informal approach: pre- and post- conditions  A semi-formal approach: UML, and its OCL  A formal approach: a set-theoretic framework for components

Contents  Is there a role for formality?  Formalisation of a software component Static characteristics (structure) Static characteristics (structure) Dynamic characteristics (behaviour) Dynamic characteristics (behaviour)

Introducing Formality  Formal methods is the use of mathematics to specify, model, develop and reason about computing systems  Delays coding  Sometimes difficult to grasp  But… unmanned Paris Metro trains don’t crash as regularly as Windows do! crash as regularly as Windows do!

Formalising components  Component-based development could benefit from a formal component model which would allow us to make safe assumptions on: the order in which methods of the component’s provided interfaces are called the order in which methods of the component’s provided interfaces are called the order in which the component calls methods on its required interfaces the order in which the component calls methods on its required interfaces

A typical software component IName1 IName2 IName3 > CName

Static characteristics (structure)  A component in UML, and elsewhere, is viewed as a black box which communicates via a set of provided and required interfaces  Each interface (assuming the oo paradigm) has a number of methods; these are invoked by the component that requires the interface and are implemented by the component that provides the interface

Static characteristics (structure) Formally,  Let I be the set of interfaces of a component and M be the set of methods. We define a component sort to be a tuple where is the set of provided interfaces is the set of provided interfaces is the set of required interfaces is the set of required interfaces hence, is the set of methods associated with interface hence, is the set of methods associated with interface

Example I = {ISearchFre, IFineTune, IDetectSignal}, M = {a 1, a 2, b 1, b 2, b 3, c 1 } P = {ISearchFre, IFineTune} R = {IDetectSignal} β(ISearchFre) = {a 1, a 2 } β(IFineTune) = {b 1, b 2, b 3 } β(IDetectSignal) = {c 1 } ISearchFre IFineTune IDetectSignal > CMenu {a 1, a 2 } {b 1, b 2, b 3 } {c 1 }

Dynamics (behaviour)  In a period of operation, each interface of the component will experience a sequence of method calls (either incoming or outgoing)  The idea is that behaviour of the component as a whole, can be described by assigning to each interface a sequence

Dynamics (behaviour) Suppose that is a component sort. We define V to be the set of all functions such that for each We shall refer to elements of V as component vectors. Formally,

In further explanation…  We form sets of vectors  Each coordinate corresponds to an interface of the component  Each coordinate contains a sequence of methods calls that may occur on that interface Hence, for n interfaces, where......

Example cont. ISearchFre IFineTune IDetectSignal > CMenu {a 1, a 2 } {b 1, b 2, b 3 } {c 1 } Here, we are forming triples where,

Example cont. ISearchFre IFineTune IDetectSignal > CMenu {a 1, a 2 } {b 1, b 2, b 3 } {c 1 } V = { (Λ, Λ, Λ), (a 1, Λ, Λ), (Λ, b 1, Λ), (a 1 a 2, Λ, Λ), (Λ, b 1 b 2, Λ), (Λ, b 1 b 3, Λ), (a 1, b 1 b 2, Λ), (a 1 a 2, Λ, c 1 ), (a 1 a 2, b 1, Λ), (a 1, b 1, Λ), (a 1, b 1 b 2 b 3, Λ), (a 1 a 2, b 1, c 1 ) }

Formalisation of a component Definition: A component is a pair where, is the sort of is the sort of is the set of component vectors of is the set of component vectors of The notion of sort embodies the static characteristics while the dynamic characteristics are captured by the notion of component vectors