Lecture Building reliable component-based systems - Chapter 2: Specification of software components. This chapter presents the following content: Current component specification techniques, specifying the semantics of components, specifying extra-functional properties of components.
Chapter Specification of Software Components Building Reliable Componentbased Overview Current Component Specification Techniques Specifying the Semantics of Components Specifying Extra-Functional Properties of Components Summary Building Reliable Componentbased What Is a Component Comprised of? Some Code… The code represents the operations that the component will perform when invoked An interface… The interface tells the component-user everything he needs to know in order to deploy the component The interface of a component should provide all the information needed by its users The specification of a component is therefore the specification of its interface Building Reliable Componentbased The Specification of an Interface This must consist solely of: A precise definition of the component's operations All context dependencies Building Reliable Componentbased Usefulness of Component Specification For users, The specification provides a definition of its interface, viz its operations and context dependencies Since it is only the interface that is visible to users, its specification must be precise and complete For developers, The specification of a component also provides an abstract definition of its internal structure Building Reliable Componentbased Current Component Specification Techniques syntactic specifications Microsoft’s Component Object Model (COM) Common Object Request Broker Architecture (CORBA) JavaBeans Building Reliable Componentbased Components and Interfaces A component provides: The implementation of a set of named interfaces, or types, each interface being a set of named operations The following diagram is a UML metamodel This model allows an interface to be implemented by several different components, and an operation to be part of several different interfaces Building Reliable Componentbased Components and Interfaces Illustrated Component 1 * Name * * in-interfaces * Interface 1 * out-interfaces * Operation 1 * Type Parameter * InParameter OutParameter InOutParameter Building Reliable Componentbased Model explained The model presents a generic representation of: The relationships between components, interfaces, and operations One can distinguish between: Object Oriented specifications and Procedural specifications Building Reliable Componentbased IDL Example interface ISpellCheck : IUnknown { HRESULT check([in] BSTR *word, [out] bool *correct); }; interface ICustomSpellCheck : IUnknown { HRESULT add([in] BSTR *word); HRESULT remove([in] BSTR *word); }; library SpellCheckerLib { coclass SpellChecker { }; [default] interface ISpellCheck; interface ICustomSpellCheck; }; Building Reliable Componentbased A Post-condition Is an assertion that the component guarantees will hold just after an operation has been invoked, provided the operation’s pre-conditions were true when it was invoked Is a predicate over both input and output parameters as well as the state just before the invocation and just after Building Reliable Componentbased An Invariant Is a predicate over the interface’s state model that will always hold A set of invariants may be associated with an interface Building Reliable Componentbased Interface specification diagram «interface type» ISpellCheck check(in word : String, out correct : Boolean) : HRESULT «interface type» ICustomSpellCheck add(in word : String) : HRESULT remove(in word : String) : HRESULT words String * words String * This model allows the same state to be associated with several interfaces Building Reliable Componentbased Semantic Specification in a UML metamodel Constraint Component * * * * State in-interfaces * Interface * 1 * * out-interfaces * * Invariant * * * PreCondition Operation * * * 1 * InParameter Parameter PostCondition * * * OutParameter * Building Reliable Componentbased * * Interface Specification context ISpellCheck::check(in word : String, out correct : Boolean): HRESULT pre: word “” post: SUCCEEDED(result) implies correct = words->includes(word) context ICustomSpellCheck::add(in word : String) : HRESULT pre: word “” post: SUCCEEDED(result) implies words = words@pre->including (word) context ICustomSpellCheck::remove(in word : String) : HRESULT pre: word “” post: SUCCEEDED(result) implies words = words@pre->exluding(word) Building Reliable Componentbased Component specification diagram Similarly to interface specification diagrams, components specification diagrams are used to specify which interfaces components provide and require «comp spec» SpellChecker ISpellCheck ICustomSpellCheck Specifying a component that provides interfaces Building Reliable Componentbased Inter-interface Constraints The component specification is completed by the specification of its inter-interface constraints, an example constraint is formulated in OCL below context SpellChecker ISpellCheck::words = ICustomSpellCheck::words Building Reliable Componentbased Interface dependency SomeComponent ISomeInterface IAnotherInterface IUsedInterface Building Reliable Componentbased Realization Contracts We can also specify realization contracts using collaboration interaction diagrams Whenever the operation op1 is called, a component supporting this operation must invoke the operation op2 in some other component 1: op1 /ISomeInterface 1.1: op2 /IUsedInterface Building Reliable Componentbased Specifying Extra-Functional Properties Conventional software doctrine is the view that software specifications must be: Sufficient Complete Static Homogeneous Building Reliable Componentbased Credentials A Credential is a triple Attribute: is a description of a property of a component Value: is a measure of that property Credibility: is a description of how the measure has been obtained Attributes in NET A component developer can associate attribute values with a component and define new attributes by subclassing an existing attribute class Building Reliable Componentbased Architectural component Structural properties Governing how a component can be composed with other components Extra-functional properties Such as performance, capacity, and environmental assumptions Family properties Specifying relations among similar or related components Building Reliable Componentbased Ensemble In Ensemble, a set of credentials may be associated with a single technology, product, or component, or with a group of such elements A UML metamodel with the concepts of syntactic specification augmented with credentials is shown in the following slide Building Reliable Componentbased Extra-functional Properties Component * * Credential Attribute Value Credibility IsPostulate : Boolean * * in-interfaces * Interface * * * out-interfaces * Operation 1 * Type Parameter * Building Reliable Componentbased Summary A component has two parts: an interface and some code In current practice, component specification techniques specify components only syntactically The use of UML and OCL to specify components represents a step towards semantic specifications Specification of extra-functional properties of components is still an open area of research, and it is uncertain what impact it will have on the future of software component specification Building Reliable Componentbased ... Specification Techniques Specifying the Semantics of Components Specifying Extra-Functional Properties of Components Summary Building Reliable Componentbased What Is a Component Comprised of? ... extra-functional properties of components is still an open area of research, and it is uncertain what impact it will have on the future of software component specification Building Reliable Componentbased ... interface Building Reliable Componentbased Interfaces A component: Implements a set of interfaces that each consists of a set of operations In addition, a set of pre-conditions and post-conditions