Chapter 10 Introduction to Components - PowerPoint PPT Presentation

About This Presentation
Title:

Chapter 10 Introduction to Components

Description:

Adapted from Software Design: From Programming to ... Introspection: Runtime Java Information Includes ... Name, parameters, return type, exceptions ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 32
Provided by: ericb171
Category:

less

Transcript and Presenter's Notes

Title: Chapter 10 Introduction to Components


1
Chapter 10Introduction to Components
2
Process Phases Discussed in This Chapter
Requirements Analysis
Design
Architecture
Framework
Detailed Design
Implementation
Key
secondary emphasis
main emphasis
x
x
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
3
Learning Goals for This Chapter
Understand
  • benefits of components
  • what components consist of
  • how they are developed
  • how they are combined
  • with each other
  • with applications
  • how components can be executed

Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
4
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.
5
Building With and Without Components
Without components
This affected by window change
With components Parts replaceable without
significant rebuilding
This affected by window change
etc.
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
6
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.
7
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.

Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
8
The Controlled Juggler Application
9
BeanBox Environment
10
Selecting Juggler
11
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
  • 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 )

Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
12
Observations on Juggler Source Code 2
  • 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 ) ..

Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
13
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.
14
Causing ExplicitButton Press to
callstopJuggling() on Juggler
15
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.
16
What Components Provide The Parts
of a Component
  • Set of classes
  • providing interfaces
  • Manifest
  • See below
  • Properties
  • Methods
  • in the form of methods, published in interfaces
  • Reactions to Events
  • Ability to provide information about themselves

Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
17
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.
18
Introspection Runtime Java Information Includes
Class Name, 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.
19
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.
20
UML Notation for Components
interfaces supported
components
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
21
Phases of a Components Lifetime
Collection of classes manifest
Design / Implementation Time
Instance Creation Time
instance
Assembly Time
application
Deployment Time
x
x
executable
Performed in a development environment e.g.,
BeanBox
Execution Time
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
22
Design Phase for Components
  • 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 components parts

Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
23
Instance Creation Time
Create instance
Store instance
component instance
component
Compiled collection of classes
Component environment
Storage
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
24
Assembly Time
Related instances
Instance creation and connection
Components
Storage
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
25
Deployment Time
Execution environment
Storage
component
Compiled classes of the application
Complete application
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
26
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.
27
Components in CORBA Have Ports
  • Facets (functionality provided for clients)
  • Receptacles (functionality it requires)
  • Dependence on other components
  • Event sources (that its 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.
28
Ports
receptacles
(Methods)
facets
event sink
attributes
(Properties)
event source
(Events)
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
29
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.
30
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.
31
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

Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
Write a Comment
User Comments (0)
About PowerShow.com