26
SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn: benefits of components what components consist of how they are developed and combined with each other and with applications how components can be executed Ch 10 Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn: benefits

Embed Size (px)

Citation preview

Page 1: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Obj

ecti

ves

Lecture # 18Introduction to Components

SWE 316: Software Design and Architecture

To learn: benefits of components what components consist of how they are developed and

combined with each other and with applications

how components can be executed

Ch 10

Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

Page 2: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Process Phases Discussed in This ChapterRequirements

Analysis

Design

Implementation

ArchitectureFramework Detailed Design

xKey: = secondary emphasisx = main emphasis

We want to re-use collections of software.

KEY CONCEPTDesign Goal At: Reusability

Introduction ExampleComponent

PartsUML Notation 2/26

Page 3: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Component-based software engineering * Component-based software engineering (CBSE)

is an approach to software development that relies on software reuse.

It emerged from the failure of object-oriented development to support effective reuse. Single object classes are too detailed and specific.

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

* Software Engineering - Sommerville

Introduction ExampleComponent

PartsUML Notation 3/26

Page 4: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Without components

With components: Parts replaceable without significant rebuilding

This affected by window change

This affected by window change

etc.

Building With and Without Components

Introduction ExampleComponent

PartsUML Notation 4/26

Page 5: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

What is a Component? -- a software collection used without

alteration.

The Object Management Group “A physical, replaceable part of a system

that packages implementation and provides the realization of a set of interfaces. A component represent a physical piece of a system’s implementation, including software code (source, binary or executable) or equivalents, such as scripts or command files”

Introduction ExampleComponent

PartsUML Notation 5/26

Page 6: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Components Can Be Made of … … Source code

Classes -- one or more, possibly related

… Executable code Object code Virtual object code

… Other files Images, text, indices, etc.

Introduction ExampleComponent

PartsUML Notation 6/26

Page 7: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Components and objects * Components are deployable entities. Components do not define types. Component implementations are

opaque. Components are language-

independent. Components are standardised.

* Software Engineering - Sommerville

Introduction ExampleComponent

PartsUML Notation 7/26

Page 8: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Component models A component model is a definition of standards for

component implementation, documentation and deployment.

Examples of component models EJB model (Enterprise Java Beans) COM+ model (.NET model) Corba Component Model

The component model specifies how interfaces should be defined and the elements that should be included in an interface definition.

Introduction ExampleComponent

PartsUML Notation 8/26

Page 9: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

The Controlled Juggler Application

Introduction ExampleComponent

PartsUML Notation 9/26

Page 10: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

BeanBox Environment

Introduction ExampleComponent

PartsUML Notation 10/26

Page 11: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Selecting Juggler

Introduction ExampleComponent

PartsUML Notation 11/26

Page 12: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Observations on Juggler Source Code 1 Juggler is a class – actually an Applet, so it

implements the Serializable interface

We do not alter (the code for) Juggler

BeanBox recognizes that Juggler is a Component, and displays an image of an instance.

Juggler listens for several kinds of events

Introduction ExampleComponent

PartsUML Notation 12/26

Page 13: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Observations on Juggler Source Code 2BeanBox recognizes that Juggler implements the

Runnable interface, and automatically executes its run()

Juggler operates by displaying images from the

array images of type Image[]. The key lines in

run() are Image img = images[ ( loop % 4 ) + 1 ];…g.drawImage( img, 0, 0, this );

Introduction ExampleComponent

PartsUML Notation 13/26

Page 14: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Observations on Juggler Source Code 2rate is a private variable: A public method

is available to set it as follows. public void setAnimationRate( int x ) { rate = x;}

BeanBox recognizes animationRate as an int property, and allows it to be set. 

Introduction ExampleComponent

PartsUML Notation 14/26

Page 15: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Observations on Juggler Source Code 2

Juggler code distinguishes the behavior of the bean between “design time,” “run time” etc. For example/*

* If switching to runtime, …

* If switching to design time and debugging is true, ….

*/

public void setDesignTime( boolean dmode ) …..

We want to construct and re-use a Juggler instance connected to Start / Stop buttons.

KEY CONCEPTDesign Goal At: Reusability

Introduction ExampleComponent

PartsUML Notation 15/26

Page 16: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Adding behaviorCausing ExplicitButton Press to call stopJuggling() on Juggler

We want the functionality and event sensitivity of a Bean to be available in any context.

KEY CONCEPTDesign Goal At: Reusability

Introduction ExampleComponent

PartsUML Notation 16/26

Page 17: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

The Parts of a Component

Properties

Methods in the form of

methods, published in interfaces

Reactions to Events Ability to provide

information about themselves

Set of classesproviding

interfaces

ManifestSee below

10.3

Referred as PME modelProperties/Methods/

Events

Introduction Example Component Parts

UML Notation 17/26

Page 18: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Manifests Identification of the component

Authorship of the component

List of files or classes making up this component

Other components on which this one relies  

Encryption information

Means of verifying that all parts of the component are present 

Version number

properties, functionality, sensitivity to events, a manifest listing its files, and an interface providing a self-description.

KEY CONCEPTThe Aspects of a Component

Introduction Example Component Parts

UML Notation 18/26

Page 19: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Introspection

Class Name, superclass, super-interfaces, inner classes, fields, constructors, Mmethods

Field Name, type

Constructor Parameters, exceptions

Method Name, parameters, return type, exceptions

Runtime Java Information Includes

Introduction Example Component Parts

UML Notation 19/26

Page 20: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

componentsinterfacessupported

UML Notation for Components

10.4

Introduction ExampleComponent

PartsUML

Notation20/26

Page 21: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Assembly Time*

Deployment Time

Execution Time

xx

Design / Implementation Time

Instance Creation Time*instance

application

executable

Collection of classes; manifest

* Performed in a development environment e.g., BeanBox

Phases of a Component’s Lifetime

Introduction ExampleComponent

PartsUML

Notation21/26

Page 22: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

1- Design/ Implementation Phase Write source code for classes

Ensure that the runtime environment contains library classes required

Conform with required rules, if any (e.g., Java Beans)

Incorporate required non-library classes

Create a manifest listing the component’s parts

Introduction ExampleComponent

PartsUML

Notation22/26

Page 23: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Compiled collection of classes

componentinstance

Component environment Storage

componentCreate instance Store instance

2- Instance Creation Time

Introduction ExampleComponent

PartsUML

Notation23/26

Page 24: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Components

Relatedinstances

Instance creation and connection

Storage

3- Assembly Time

Introduction ExampleComponent

PartsUML

Notation24/26

Page 25: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Compiled classes of the application

component

Executionenvironment Storage

Complete application

4- Deployment Time

Select, design, code source, instantiate, combine instances, deploy in applications, execute.

KEY CONCEPTThe Lifecycle of a Component

Introduction ExampleComponent

PartsUML

Notation25/26

Page 26: SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits

SWE 316: Software Design and Architecture

Summary: Components …

… are software elements used without alteration

… allow the re-use of compiled parts

Interaction via events reduces interdependence

… typically developed in a convenient container

e.g., for visualizing and interconnecting

to free the developer from common tasks

… consist of classes, files etc. and a manifest

Introduction ExampleComponent

PartsUML Notation 26/26