110 likes | 124 Views
Seminarium on Component-based Software Engineering. Component interfaces. Marcello Bonsangue LIACS – Leiden University Fall 2005. Interfaces. A component interface define mean to connect a a component In a component based application providers and clients are ignorant of each other
E N D
Seminarium onComponent-based Software Engineering Component interfaces Marcello Bonsangue LIACS – Leiden University Fall 2005
Interfaces • A component interface define mean to connect a a component • In a component based application providers and clients are ignorant of each other • A component can have multiple interfaces • To offer multiple services (possibly with overlapping functionalities) • To allow for multiple versions to live together Seminarium CBSE
Interfaces (II) • For reachability, interfaces should be named according to a unique naming scheme (at least productwise) • Example: • ISBN, an international identifier for each published book • No meaning, only identity • E.g. two different books with the same title Seminarium CBSE
Provided and required interfaces • Provided interface • A specification of what the component provides to its deployment environment • Required interface • A specification of what the deployment environment needs to provide in order the component to function properly Seminarium CBSE
Direct and indirect interfaces • An interface is often a set of named operations that can be invoked by a client • A component can directly provide interfaces as procedural libraries or there can be interfaces provided indirectly by objects made available by the component. Seminarium CBSE
Indirect interface • An indirect interface uses a technique called dispatch which can lead to involvement of a third party which might be unknown to both client and the provider Word processing comp. Grammar checking comp. Word processor class Grammar checker class Has-a Has-a Implements Has-a Text services class Checker interface Text services component Seminarium CBSE
Versioning • Version management is traditionally based on a comparison between numbers to provide upward compatibility • With direct interfaces it suffices to check the version number at bind-time • With indirect interfaces a reference to a compatible version may be passed to another component creating incompatibility • Solution 1: check version number each time a reference cross component boundaries • Solution 2: Interfaces are immutable and multiple versions may live together Seminarium CBSE
Contracts • An interface is a contract between a client of the interface and a provider of its implementation • The contract can be captured by pre-and post-conditions for each operation • The client has to establish the pre-condition before executing an operation • The provider can rely on the pre-condition being met before a call to the operation • The provider has to establish the post-condition before returning to the client • The client can rely on the post-condition being met when the operation returns. Seminarium CBSE
What must be in a contract? • Relevant functional features • Non-functional requirement • Performance • Space requirements • It must be precise but not too restrictive Seminarium CBSE
How can we write a contract • Hoare triples {Pre} operation {Post} • Partial correctness • Total correctness • Temporal logic • Progress (leads-to, eventually) • Safety (Invariants, always) • Fairness (eventually always) • With time and space bounds • Average cases • Together with platform-dependent measurments • Informally, in precise but plain English • Several interpretations can be found • Analogy with real-world laws Seminarium CBSE
Independent extensibility • A system is independently extensible if it is extensible and independently developed extensions can be combined • Examples: • Operating Systems can load and execute applications • WWW-Browsers: plug-ins Seminarium CBSE