Component-based software engineering · PDF fileComponent-based software engineering ©Ian...

48
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 1 Component-based software engineering

Transcript of Component-based software engineering · PDF fileComponent-based software engineering ©Ian...

Page 1: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 1

Component-based softwareengineering

Page 2: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2

Objectives

● To explain that CBSE is concerned withdeveloping standardised components andcomposing these into applications

● To describe components and componentmodels

● To show the principal activities in the CBSEprocess

● To discuss approaches to componentcomposition and problems that may arise

Page 3: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 3

Topics covered

● Components and component models

● The CBSE process

● Component composition

Page 4: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 4

Component-based development

● Component-based software engineering(CBSE) is an approach to softwaredevelopment that relies on software reuse.

● It emerged from the failure of object-orienteddevelopment to support effective reuse.Single object classes are too detailed andspecific.

● Components are more abstract than objectclasses and can be considered to be stand-alone service providers.

Page 5: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 5

CBSE essentials

● Independent components specified by theirinterfaces.

● Component standards to facilitatecomponent integration.

● Middleware that provides support forcomponent inter-operability.

● A development process that is geared toreuse.

Page 6: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 6

CBSE and design principles

● Apart from the benefits of reuse, CBSE isbased on sound software engineering designprinciples:• Components are independent so do not

interfere with each other;• Component implementations are hidden;• Communication is through well-defined

interfaces;• Component platforms are shared and reduce

development costs.

Page 7: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 7

CBSE problems

● Component trustworthiness - how can a componentwith no available source code be trusted?

● Component certification - who will certify the qualityof components?

● Emergent property prediction - how can theemergent properties of component compositions bepredicted?

● Requirements trade-offs - how do we do trade-offanalysis between the features of one componentand another?

Page 8: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 8

Components

● Components provide a service withoutregard to where the component is executingor its programming language• A component is an independent executable

entity that can be made up of one or moreexecutable objects;

• The component interface is published and allinteractions are through the published interface;

Page 9: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 9

Component definitions

● Councill and Heinmann:• A software component is a software element that

conforms to a component model and can beindependently deployed and composed withoutmodification according to a composition standard.

● Szyperski:• A software component is a unit of composition with

contractually specified interfaces and explicit contextdependencies only. A software component can bedeployed independently and is subject to composition bythird-parties.

Page 10: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 10

Component as a service provider

● The component is an independent,executable entity. It does not have to becompiled before it is used with othercomponents.

● The services offered by a component aremade available through an interface and allcomponent interactions take place throughthat interface.

Page 11: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 11

Component characteristics 1

Standardised Component standardisation means that a component that isused in a CBSE process has to conform to some standardisedcomponent model. This model may define componentinterfaces, component meta-data, documentation, compositionand deployment.

Independent A component should be independent – it should be possible tocompose and deploy it without having to use other specificcomponents. In situations where the component needsexternally provided services, these should be explicitly set outin a ‘requires’ interface specification.

Composable For a component to be composable, all external interactionsmust take place through publicly defined interfaces. Inaddition, it must provide external access to information aboutitself such as its methods and attributes.

Page 12: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 12

Component characteristics 2

Deployable To be deployable, a component has to be self-contained andmust be able to operate as a stand-alone entity on somecomponent platform that implements the component model.This usually means that the component is a binary componentthat does not have to be compiled before it is deployed.

Documented Components have to be fully documented so that potentialusers of the component can decide whether or not they meettheir needs. The syntax and, ideally, the semantics of allcomponent interfaces have to be specified.

Page 13: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 13

Component interfaces

● Provides interface• Defines the services that are provided by the

component to other components.

● Requires interface• Defines the services that specifies what

services must be made available for thecomponent to execute as specified.

Page 14: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 14

Component interfaces

Page 15: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 15

A data collector component

Page 16: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 16

Components and objects

● Components are deployable entities.

● Components do not define types.

● Component implementations are opaque.

● Components are language-independent.

● Components are standardised.

Page 17: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 17

Component models

● A component model is a definition of standards forcomponent implementation, documentation anddeployment.

● Examples of component models• EJB model (Enterprise Java Beans)

• COM+ model (.NET model)

• Corba Component Model

● The component model specifies how interfacesshould be defined and the elements that should beincluded in an interface definition.

Page 18: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 18

Elements of a component model

Page 19: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 19

Middleware support

● Component models are the basis for middlewarethat provides support for executing components.

● Component model implementations provide:• Platform services that allow components written

according to the model to communicate;• Horizontal services that are application-independent

services used by different components.

● To use services provided by a model, componentsare deployed in a container. This is a set ofinterfaces used to access the serviceimplementations.

Page 20: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 20

Component model services

Page 21: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 21

Component development for reuse

● Components developed for a specificapplication usually have to be generalised tomake them reusable.

● A component is most likely to be reusable if itassociated with a stable domain abstraction(business object).

● For example, in a hospital stable domainabstractions are associated with thefundamental purpose - nurses, patients,treatments, etc.

Page 22: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 22

Component development for reuse

● Components for reuse may be specially constructed bygeneralising existing components.

● Component reusability• Should reflect stable domain abstractions;• Should hide state representation;• Should be as independent as possible;• Should publish exceptions through the component

interface.● There is a trade-off between reusability and usability

• The more general the interface, the greater the reusabilitybut it is then more complex and hence less usable.

Page 23: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 23

Changes for reusability

● Remove application-specific methods.

● Change names to make them general.

● Add methods to broaden coverage.

● Make exception handling consistent.

● Add a configuration interface for componentadaptation.

● Integrate required components to reducedependencies.

Page 24: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 24

Legacy system components

● Existing legacy systems that fulfil a usefulbusiness function can be re-packaged ascomponents for reuse.

● This involves writing a wrapper componentthat implements provides and requiresinterfaces then accesses the legacy system.

● Although costly, this can be much lessexpensive than rewriting the legacy system.

Page 25: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 25

Reusable components

● The development cost of reusablecomponents may be higher than the cost ofspecific equivalents. This extra reusabilityenhancement cost should be an organizationrather than a project cost.

● Generic components may be lessspace-efficient and may have longerexecution times than their specificequivalents.

Page 26: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 26

The CBSE process

● When reusing components, it is essential tomake trade-offs between ideal requirementsand the services actually provided byavailable components.

● This involves:• Developing outline requirements;• Searching for components then modifying

requirements according to availablefunctionality.

• Searching again to find if there are bettercomponents that meet the revisedrequirements.

Page 27: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 27

The CBSE process

Page 28: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 28

The component identification process

Page 29: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 29

Component identification issues

● Trust. You need to be able to trust the supplier of acomponent. At best, an untrusted component maynot operate as advertised; at worst, it can breachyour security.

● Requirements. Different groups of components willsatisfy different requirements.

● Validation.• The component specification may not be detailed enough

to allow comprehensive tests to be developed.• Components may have unwanted functionality. How can

you test this will not interfere with your application?

Page 30: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 30

Ariane launcher failure

● In 1996, the 1st test flight of the Ariane 5 rocketended in disaster when the launcher went out ofcontrol 37 seconds after take off.

● The problem was due to a reused component from aprevious version of the launcher (the InertialNavigation System) that failed because assumptionsmade when that component was developed did nothold for Ariane 5.

● The functionality that failed in this component wasnot required in Ariane 5.

Page 31: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 31

Component composition

● The process of assembling components tocreate a system.

● Composition involves integratingcomponents with each other and with thecomponent infrastructure.

● Normally you have to write ‘glue code’ tointegrate components.

Page 32: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 32

Types of composition

● Sequential composition where the composedcomponents are executed in sequence. Thisinvolves composing the provides interfaces of eachcomponent.

● Hierarchical composition where one component callson the services of another. The provides interface ofone component is composed with the requiresinterface of another.

● Additive composition where the interfaces of twocomponents are put together to create a newcomponent.

Page 33: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 33

Types of composition

Page 34: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 34

Interface incompatibility

● Parameter incompatibility where operationshave the same name but are of differenttypes.

● Operation incompatibility where the namesof operations in the composed interfaces aredifferent.

● Operation incompleteness where theprovides interface of one component is asubset of the requires interface of another.

Page 35: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 35

Incompatible components

Page 36: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 36

Adaptor components

● Address the problem of componentincompatibility by reconciling the interfacesof the components that are composed.

● Different types of adaptor are requireddepending on the type of composition.

● An addressFinder and a mapper componentmay be composed through an adaptor thatstrips the postal code from an address andpasses this to the mapper component.

Page 37: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 37

address = addressFinder.location (phonenumber) ;postCode = postCodeStripper.getPostCode (address) ;mapper.displayMap(postCode, 10000)

Composition through an adaptor

● The component postCodeStripper is theadaptor that facilitates the sequentialcomposition of addressFinder and mappercomponents.

Page 38: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 38

Adaptor for data collector

Page 39: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 39

Interface semantics

● You have to rely on componentdocumentation to decide if interfaces that aresyntactically compatible are actuallycompatible.

● Consider an interface for a PhotoLibrarycomponent:

public void addItem (Identifier pid ; Photograph p; CatalogEntry photodesc) ;public Photograph retrieve (Identifier pid) ;public CatalogEntry catEntry (Identifier pid) ;

Page 40: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 40

Photo library composition

Page 41: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 41

Photo Library documentation

“This method adds a photograph to the library andassociates the photograph identifier and cataloguedescriptor with the photograph.”

“what happens if the photograph identifier is alreadyassociated with a photograph in the library?”“is the photograph descriptor associated with thecatalogue entry as well as the photograph i.e. if I deletethe photograph, do I also delete the catalogueinformation?”

Page 42: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 42

The Object Constraint Language

● The Object Constraint Language (OCL) hasbeen designed to define constraints that areassociated with UML models.

● It is based around the notion of pre and postcondition specification - similar to theapproach used in Z as described in Chapter10.

Page 43: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 43

Formal description of photo library

-- The context keyword names the component to which the conditions applycontext addItem

-- The preconditions specify what must be true before execution of addItempre: PhotoLibrary.libSize() > 0

PhotoLibrary.retrieve(pid) = null

-- The postconditions specify what is true after executionpost: libSize () = libSize()@pre + 1

PhotoLibrary.retrieve(pid) = pPhotoLibrary.catEntry(pid) = photodesc

context delete

pre: PhotoLibrary.retrieve(pid) <> null ;

post: PhotoLibrary.retrieve(pid) = nullPhotoLibrary.catEntry(pid) = PhotoLibrary.catEntry(pid)@prePhotoLibrary.libSize() = libSize()@pre - 1

Page 44: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 44

Photo library conditions

● As specified, the OCL associated with the PhotoLibrary component states that:• There must not be a photograph in the library with the

same identifier as the photograph to be entered;

• The library must exist - assume that creating a libraryadds a single item to it;

• Each new entry increases the size of the library by 1;

• If you retrieve using the same identifier then you get backthe photo that you added;

• If you look up the catalogue using that identifier, then youget back the catalogue entry that you made.

Page 45: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 45

Composition trade-offs

● When composing components, you may findconflicts between functional and non-functionalrequirements, and conflicts between the need forrapid delivery and system evolution.

● You need to make decisions such as:• What composition of components is effective for

delivering the functional requirements?

• What composition of components allows for futurechange?

• What will be the emergent properties of the composedsystem?

Page 46: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 46

Data collection and report generation

Page 47: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 47

Key points

● CBSE is a reuse-based approach to defining andimplementing loosely coupled components intosystems.

● A component is a software unit whose functionalityand dependencies are completely defined by itsinterfaces.

● A component model defines a set of standards thatcomponent providers and composers should follow.

● During the CBSE process, the processes ofrequirements engineering and system design areinterleaved.

Page 48: Component-based software engineering · PDF fileComponent-based software engineering ©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 2 ... • The component

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 19 Slide 48

Key points

● Component composition is the process of‘wiring’ components together to create asystem.

● When composing reusable components, younormally have to write adaptors to reconciledifferent component interfaces.

● When choosing compositions, you have toconsider required functionality, non-functional requirements and systemevolution.