CompBasedSoftwEng Ian Sommervile Super Za Uvod

Embed Size (px)

Citation preview

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    1/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 1

    Component-based software

    engineering

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    2/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering 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

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    3/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 3

    Topics covered

    Components and component models

    The CBSE process

    Component composition

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    4/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering 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. Singleobject classes are too detailed and specific.

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

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    5/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 5

    CBSE essentials

    Independent components specified by theirinterfaces.

    Component standards to facilitate component

    integration. Middleware that provides support for

    component inter-operability.

    A development process that is geared toreuse.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    6/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering 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 interferewith each other;

    Component implementations are hidden;

    Communication is through well-defined interfaces;

    Component platforms are shared and reducedevelopment costs.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    7/57Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 7

    CBSE problems

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

    Component certification - who will certify the quality of

    components?

    Emergent property prediction - how can the emergentproperties of component compositions be predicted?

    Requirements trade-offs - how do we do trade-off

    analysis between the features of one component and

    another?

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    8/57Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 8

    Components

    Components provide a service without regardto where the component is executing or itsprogramming language A component is an independent executable entity

    that can be made up of one or more executableobjects;

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

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    9/57Ian Sommerville 2006 MSc module: Advanced Software Engineering 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 without

    modification according to a composition standard.

    Szyperski: A software component is a unit of composition with

    contractually specified interfaces and explicit

    context dependencies only. A software componentcan be deployed independently and is subject tocomposition by third-parties.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    10/57Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 10

    Component as a service provider

    The component is an independent, executableentity. It does not have to be compiled before itis used with other components.

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

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    11/57Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 11

    Component characteristics 1

    Standardised Component standardisation means that a component that is

    used in a CBSE process has to conform to some standardised

    component model. This model may define component

    interfaces, component meta-data, documentation, composition

    and deployment.

    Independent A component should be independent it should be possible to

    compose and deploy it without having to use other specific

    components. In situations where the component needs

    externally provided services, these should be explicitly set out

    in a requiresinterface specification.

    Composable For a component to be composable, all external interactionsmust take place through publicly defined interfaces. In

    addition, it must provide external access to information about

    itself such as its methods and attributes.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    12/57Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 12

    Component characteristics 2

    Deployable To be deployable, a component has to be self-contained and

    must be able to operate as a stand-alone entity on some

    component platform that implements the component model.This usually means that the component is a binary component

    that does not have to be compiled before it is deployed.

    Documented Components have to be fully documented so that potential

    users of the component can decide whether or not they meet

    their needs. The syntax and, ideally, the semantics of all

    component interfaces have to be specified.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    13/57Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 13

    Component interfaces

    Provides interface

    Defines the services that are provided by thecomponent to other components.

    Requires interface Defines the services that must be made available

    for the component to execute as specified.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    14/57Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 14

    Component interfaces

    Provides int erf aceRequires int erf ace

    Component

    Defines th e services

    fromthecomponents

    environment t hat i t

    uses

    Defines th e services

    that are prov ided

    by the componen t

    to other componen ts

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    15/57Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 15

    Provides/requires interfaces

    These interfaces are NOT the same as input/outputinterfaces.

    Both of these interfaces define both the inputs neededand the outputs produced by the provided and

    required services Requires

    You can think of this as defining the methods that arecalled by a component or before a component executes

    Provides

    You can think of this as defining how the component iscalled.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    16/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 16

    A data collector component

    Provides int erf aceRequires int erf ace

    Data collector

    addSensor

    removeSensorstartSensor

    stopSensor

    testSensor

    listAllreport

    initialise

    sensorManagement

    sensorData

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    17/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 17

    Components and objects

    Components are deployable entities.

    Components do not define types.

    Component implementations are opaque.

    Components are language-independent.

    Components are standardised.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    18/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 18

    Component models

    A component model is a definition of standardsfor component implementation, documentationand deployment.

    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 thatshould be included in an interface definition.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    19/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 19

    Elements of a component model

    Component model

    Interfaces

    Usage

    information

    Deployment

    and use

    Interface

    definition

    Speci fic

    interfaces

    Composi tion

    Naming

    convention

    Meta-data

    access

    Customisation

    Packaging

    Documentation

    Evolution

    support

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    20/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 20

    Middleware support

    Component models are the basis for middleware thatprovides support for executing components.

    Component model implementations provide:

    Platform services that allow components writtenaccording to the model to communicate;

    Horizontal services that are application-independentservices used by different components.

    To use services provided by a model, components are

    deployed in a container. This is a set of interfaces usedto access the service implementations.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    21/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 21

    Component model services

    Platform services

    AddressingInter face

    definitionComponent

    communications

    Exception

    management

    Horizontal services

    Security

    Transaction

    management

    Concurrency

    Component

    management

    Persistence

    Resource

    management

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    22/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 22

    Component development for reuse

    Components are rarely created by simplyusing part of the code of another applicationsystem

    Rather, components for reuse have to bespecifically developed so that they arereusable across a range of applications

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    23/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 23

    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.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    24/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 24

    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 componentinterface.

    There is a trade-off between reusability and usability

    The more general the interface, the greater thereusability but it is then more complex and hence lessusable.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    25/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 25

    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.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    26/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 26

    Legacy system components

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

    This involves writing a wrapper component thatimplements provides and requires interfacesthen accesses the legacy system.

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

    We will return to issues of legacy system reusein the discussion of service-oriented systems.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    27/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 27

    Reusable components

    The development cost of reusable componentsmay be higher than the cost of specificequivalents. This extra reusability

    enhancement cost should be an organizationrather than a project cost.

    Generic components may be lessspace-efficient and may have longer execution

    times than their specific equivalents.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    28/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 28

    CBSE Processes

    As discussed, conventional softwareengineering processes have to be adapted forreuse.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    29/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 29

    The CBSE process

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

    This involves: Developing outline requirements;

    Searching for components then modifyingrequirements according to available functionality.

    Searching again to find if there are bettercomponents that meet the revised requirements.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    30/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 30

    The CBSE process

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    31/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 31

    The component identification process

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    32/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 32

    Component identification issues

    Trust. You need to be able to trust the supplier of acomponent. At best, an untrusted component may notoperate as advertised; at worst, it can breach your

    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?

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    33/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 33

    Component composition

    Designing a system by integrating a number ofcomponents.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    34/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 34

    Component composition

    The process of assembling components tocreate a system.

    Composition involves integrating components

    with each other and with the componentinfrastructure.

    Normally you have to write glue code to

    integrate components.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    35/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 35

    Types of composition

    Sequential composition where the composedcomponents are executed in sequence. This involvescomposing the provides interfaces of each component.

    Hierarchical composition where one component calls

    on the services of another. The provides interface ofone component is composed with the requires interfaceof another.

    Additive composition where the interfaces of two

    components are put together to create a newcomponent.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    36/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 36

    Types of composition

    (a)

    A A

    B B

    A B

    (b) (c)

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    37/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 37

    Sequential composition

    In this case, the components are executed insequence to provide some required effect

    The outputs from the provides interface from

    the first component executed become theinputs for the provides interface for the 2ndunit called (perhaps with some modificationthrough an adapter component)

    Each component is executed independentlyand does not have to be aware of the othercomponents in the sequence.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    38/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 38

    Hierarchical composition

    In this case, one component (defined in therequires interface) is called directly from withinthe body of the other component.

    The calling component must know the nameand the interface signature of the calledcomponent.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    39/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 39

    Additive composition

    In this case, we put two components togetherso that the provides interface includesoperations that come from both of the

    composed components. Essentially, this is normally implemented by

    defining a new small component that offers thecombined interface and which than calls one of

    the composed components, depending on thecall to the composed component.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    40/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 40

    Interface incompatibility

    Parameter incompatibility where operationshave the same name but are of different types.

    Operation incompatibility where the names of

    operations in the composed interfaces aredifferent.

    Operation incompleteness where the providesinterface of one component is a subset of the

    requires interface of another.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    41/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 41

    Incompatible components

    addressFinder

    phoneDatabase (string command )s tring l ocati on(s tring p n)

    s tring owner (string pn)

    s tring propertyType (string pn)

    mapp er

    mapDB (string command)dis play Map (s tring postCode, scale)

    printMap (s tring p ost Code, scale)

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    42/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 42

    Incompatibility

    The component addressFinder through itslocation method produces a string which is theaddress of the property, including street

    number and name and town The component mapper through its

    displayMap method, expects a string which isa postcode only (not a complete address)

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    43/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 43

    Adaptor components

    Address the problem of componentincompatibility by reconciling the interfaces ofthe 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 (calledpostCodeStripper) that strips the postal codefrom an address and passes this to themapper component.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    44/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 44

    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 mapper

    components.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    45/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 45

    Adaptor for data collector

    Data collector

    addSensor

    removeSensorstartSensor

    stopSensor

    testSensor

    listAll

    report

    initialise

    sensorManagement

    sensorData

    Adaptersensor

    start

    getdata

    stop

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    46/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 46

    Adaptor functionality

    The data collector component requires asensorManagement component that providesfacilities to stop and start sensors and to query

    sensors for data The adapter component in this case turns a

    string of sensor management commands e.g.sensor.stop into the commands required for a

    specific sensor device.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    47/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 47

    Interface semantics

    You have to rely on component documentationto decide if interfaces that are syntacticallycompatible are actually compatible.

    Consider an interface for a PhotoLibrarycomponent:

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

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    48/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 48

    Photo library composition

    PhotoLibrary

    adaptorImage

    Manager

    getImage

    User

    Inter face

    getCatalogEntry

    addItem

    retrieve

    catEntry

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    49/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 49

    Photo Library documentation

    This method adds a photograph to the library and

    associates the photograph identifier and catalogue

    descriptor with the photograph.

    what happens if the photograph identifier is already

    associated with a photograph in the library?

    is the photograph descriptor associated with the

    catalogue entry as well as the photograph i.e. if I deletethe photograph, do I also delete the catalogue

    information?

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    50/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 50

    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 the approachused in Z as described in Chapter 10.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    51/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 51

    Formal description of photo library

    -- The context keyword names the component to which the condi tions apply

    context addItem

    -- The preconditions specify what must be true before execution of addItem

    pre: PhotoLibrary.libSize() > 0

    PhotoLibrary.retrieve(pid) = null

    -- The postconditions specify what is true after execution

    post: libSize () = libSize()@pre + 1

    PhotoLibrary.retrieve(pid) = p

    PhotoLibrary.catEntry(pid) = photodesc

    context delete

    pre: PhotoLibrary.retrieve(pid) null ;

    post: PhotoLibrary.retrieve(pid) = null

    PhotoLibrary.catEntry(pid) = PhotoLibrary.catEntry(pid)@pre

    PhotoLibrary.libSize() = libSize()@pre - 1

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    52/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 52

    Photo library conditions

    As specified, the OCL associated with the PhotoLibrary component states that:

    There must not be a photograph in the library with thesame 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 getback the photo that you added;

    If you look up the catalogue using that identifier, thenyou get back the catalogue entry that you made.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    53/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 53

    Composition trade-offs

    When composing components, you may findconflicts between functional and non-functionalrequirements, and conflicts between the needfor rapid 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 future

    change? What will be the emergent properties of the

    composed system?

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    54/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 54

    Data collection and report generation

    (a) Data

    collection

    (b)

    Data

    management

    Report

    generator

    Data

    collectionData base

    Report

    Report

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    55/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 55

    Composition trade-offs

    For composition (a), reporting and datamanagement are separate so there is moreflexibility if changes in one of these functions

    but not the other have to be made. For composition (b), there are fewer discrete

    components so faster communications withinthe component offering both data management

    and report generation.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    56/57

    Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 56

    Key points

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

    A component is a software unit whose functionality and

    dependencies are completely defined by its interfaces.

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

    During the CBSE process, the processes of

    requirements engineering and system design areinterleaved.

  • 8/3/2019 CompBasedSoftwEng Ian Sommervile Super Za Uvod

    57/57

    Key points

    Component composition is the process ofwiring components together to create a

    system.

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

    When choosing compositions, you have to

    consider required functionality, non-functionalrequirements and system evolution.