chapter 10 introduction to components. process phases discussed in this chapter requirements...

31
Chapter 10 Introduction to Components

Upload: tamsin-clare-carpenter

Post on 11-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Chapter 10Introduction to Components

Page 2: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Process Phases Discussed in This ChapterRequirementsAnalysis

Design

Implementation

ArchitectureFramework Detailed Design

xKey: = secondary emphasisx = main emphasis

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

Page 3: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Learning Goals for This Chapter

… benefits of components

… what components consist of

… how they are developed

… how they are combinedo with each other

o with applications

… how components can be executed

Understand …

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

Page 4: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Design Goal At Work: Reusability

We want to re-use collections of software.

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

Page 5: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Building With and Without Components

Without components

With components: Parts replaceable without significant rebuilding

This affected by window change

This affected by window change

etc.

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

Page 6: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Key Concept: What is a Component?

-- a software collection used without alteration.

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

Page 7: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Components Can Be Made of …

… Source codeo Classes -- one or more, possibly related

… Executable codeo Object code

o Virtual object code

… Other fileso Images, text, indices, etc.

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

Page 8: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

The Controlled Juggler Application

Page 9: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

BeanBox Environment

Page 10: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Selecting Juggler

Page 11: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

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

BeanBox 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 );

Observations on Juggler Source

Code 1

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

Page 12: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

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

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 ) …..

Observations on Juggler Source

Code 2

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

Page 13: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Design Goal At Work: Reusability

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

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

Page 14: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Causing ExplicitButton Press to callstopJuggling() on Juggler

Page 15: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Design Goal At Work: Reusability

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

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

Page 16: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

What Components Provide The Parts of a Component

Properties

Methods o in the form of methods,

published in interfaces

Reactions to Events Ability to provide

information about themselves

Set of classesproviding interfaces

ManifestSee below

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

Page 17: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

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

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

Page 18: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Introspection: Runtime Java Information Includes …

ClassName, superclass, super-interfaces, inner classes, fields, constructors, Mmethods

Field Name, type

Constructor Parameters, exceptions

Method Name, parameters, return type, exceptions

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

Page 19: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Key Concept: The Aspects of a Component

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

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

Page 20: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

UML Notation for Components

componentsinterfacessupported

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

Page 21: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Phases of a Component’s Lifetime

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

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

Page 22: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Design Phase for Components

Write source code for classes

o Ensure that the runtime environment contains library

classes required

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

Incorporate required non-library classes

Create a manifest listing the component’s parts

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

Page 23: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Instance Creation Time

Compiled collection of classes

componentinstance

Component environment Storage

componentCreate instance Store instance

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

Page 24: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Assembly Time

Components

Relatedinstances

Instance creation and connection

Storage

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

Page 25: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Deployment Time

Compiled classes of the application

component

Executionenvironment Storage

Complete application

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

Page 26: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Key Concept: The Lifecycle of a Component:

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

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

Page 27: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Components in CORBA Have “Ports”

Facets (functionality provided for clients)

Receptacles (functionality it requires)

Dependence on other components

Event sources (that it’s sensitive to)

Event sinks (that it listens for on other components)

Attributes (properties)

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

Page 28: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Ports

facets

attributes

event sink

event source

receptacles

(“Methods”)

(“Properties”)

(“Events”)

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

Page 29: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Component May Support Interfaces

Interface DepositTransactions { . . . };

Used in …

Component Bank supports DepositTransactions

{ … Provide additional parts as desired … };

Specification of an interface (a list of function prototypes)

Specification of a component

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

Page 30: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Finding CORBA Components and Creating Instances

Get reference to component XYBank using the CORBA naming service. (Not covered here.)

Create instances in two steps.

(1): Use create() on the component

Org.omg.Components.ComponentBase

myXYBankInstance = XYBank.create();

(2): Cast the instance as XYBank object

XYBank bank = (XYBank) myXYBankInstance;

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

Page 31: Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed

Summary: Components …

… are software elements used without alteration

… allow the re-use of compiled parts

o Interaction via events reduces interdependence

… typically developed in a convenient container

o e.g., for visualizing and interconnecting

o to free the developer from common tasks

… consist of classes, files etc. and a manifest

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