390 likes | 396 Views
Learn about component interfaces, access points, message formats, contracts, abstraction levels, and the concept of polymorphism. Discover how interfaces define connections and how polymorphism allows multiple forms with real-world examples.
E N D
Interfaces • Define the component’s access points • Will normally have multiple interfaces • Standard naming schemes needed to reference interfaces • Standardisation of message formats also needed
Interfaces (2) • Two types of interfaces • Provided interfaces • Required interfaces
Interfaces (3) Print service Required Interfaces Provided Interfaces Print GetPDFile GetQueue Remove PrinterInt Transfer Register Unregister
Interfaces (4) • Are the means by which components connect • Is a set of named operations that can be invoked by clients
Interfaces (5) • Dual role of the interface specification • Providers implementing the interface • Clients using the interface
Interfaces (6) • Component specification • A component can be specified separate from their interfaces • A component specification includes • All the interfaces that the component should support • Component-specific properties • Multiple component implementation can conform to such specification
Interfaces (7) • Versions • Immutable interfaces • Multiple versions are supported by multiple interfaces • Constrained changes • Rules define the kind of changes that are valid to retain backward compatibility
Interfaces (8) • Contracts • Interface specifications can be viewed as contracts between clients and providers • Contract state • what the client needs to do to use the interface • What the provider has to implement to meet the services define in the interface
Interfaces (9) • A popular contractual specification method • The client meets a precondition before calling the operation • The provider meets a postcondition before returning to the client
Interfaces (10) • When implementation is changed • Contracts should be maintained • At most, the provider most required less and provide more
Interfaces (11) • Non-functional requirements • A contract should include all essential functional and non-functional aspects • Specifying complexity bounds • Might include platform specific performance figures
Abstraction levels • Meyer identifies 5 abstraction levels: • Functional abstraction • Casual abstraction • Data abstraction • Cluster abstraction • System abstraction
Some more terms • Component model [Szyperski] • Defines the rules of composition
Some more terms (2) • Component Model [Wallnau] • “Is the set of component types, their interfaces, and, additionally, a specification of the allowable patterns of interaction among component types”
Some more terms (3) • Component framework • “Is a set of interfaces and rules of interaction that govern the interaction of components ‘plugged into’ them.” • Is a reusable architectural design targeting a specific domain whereby desired architectural properties and invariants are enforced
Callbacks and contracts • A callback is a procedure that is passed to a library at one point Other party Library Client Client installs callback Third party calls library Library invokes callback Callback queries library Callback returns Library returns
Callbacks and contracts (2) • Common feature in procedural libraries that have to handle asynchronous events • Windowing libraries use a callback to notify a particular window’s client code when the user resized the window
Callbacks and contracts (3) • A library can make part of its state observable by exporting variables or inspection functions • The relative order in which callbacks are performed can be observed • However, such ordering is not specified by normal pre- and postconditions
Polymorphism • Polymorphism is • The ability of something to appear in multiple forms, depending on the context
Polymorphism • Same interface • Used by large numbers of different clients • Supported by a large number of different providers • Keep balance of what is required from providers and clients
Polymorphism • If an interface requires too little from providers • it is useless • If an interface requires too much from providers or clients • it is difficult to implement
Polymorphism • A carefully crafted interface requires no more than is essential • Clients and providers are always free to overfulfill their contract
Polymorphism • Pre- and post conditions are usually specified using predicates • Which define • The permitted input and output values • The permitted values of an internal variable • Operations that should be executed • Example: • len<max and 0<=position<=max
Polymorphism • When is it legal to substitute one service provider for another? • When a provider satisfies the contract
Polymorphism • Ideally, contracts should be explicitly specified as part of an interface spec • It would be desirable to have a compiler to check contract compatibility • In reality, it is far from attainable: • Formalising contracts is difficult and expensive • Automatic checking still part of research
Polymorphism • Checking can be done at: • compiling-time • Load-time • Run-time better
Polymorphism • Type • Group of values of related semantics • Basic types, such as INTEGER and REAL, can be understood as sets of values • In case of objects and interfaces, type is a set of objects implementing a certain interface
Polymorphism • Types as simplified contracts • The types of the in-out parameters form part of: • an operation’s preconditions • An operation’s postconditions • However, other part of the pre and postconditions are not part of a type • Successful type checking does not ensure contracts are not violated
Polymorphism • Subtyping • Named subtyping (interface inheritance) • Base interfaces are named • Structural subtyping • Base interface are not named • Operations are repeated • Is a superset of operations defined by another type
Polymorphism • There is polymorphism • When a variable can refer to objects of multiple subtypes • Example: • The variable of type View can refer to objects of type View, TextView, GraphicsView, etc
Open Distributed Processing • Openness required to overcome the problems of • Complexity • Heterogeneity • ODP’s main function: • distributed services transparently located and accessed • regardless of the underlying platform
Open Distributed Processing • An open system [Coulouris]: • is one that can be extended and implemented in different ways; • for this the key interfaces must be made public
We require: • To standardise well-defined interfaces • ODP can achieve: • Interoperability • Portability • Middleware is an effort to meet ODP’s principles