260 likes | 450 Views
SWE 316: Software Design and Architecture. Lecture # 18 Introduction to Components . Ch 10. 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 .
E N D
SWE 316: Software Design and Architecture Lecture # 18Introduction to Components Ch 10 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 Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
2/26 Introduction Example Component Parts UML Notation Process Phases Discussed in This Chapter KEY CONCEPT Design Goal At: Reusability Requirements Analysis We want to re-use collections of software. Design Framework Architecture Detailed Design Implementation Key: = main emphasis = secondary emphasis x x
3/26 Introduction Example Component Parts UML Notation 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
4/26 Introduction Example Component Parts UML Notation Building With and Without Components This affected by window change Withoutcomponents With components: Parts replaceable without significant rebuilding This affected by window change etc.
5/26 Introduction Example Component Parts UML Notation 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”
6/26 Introduction Example Component Parts UML Notation 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.
7/26 Introduction Example Component Parts UML Notation 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
8/26 Introduction Example Component Parts UML Notation 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.
9/26 Introduction Example Component Parts UML Notation The Controlled Juggler Application
10/26 Introduction Example Component Parts UML Notation BeanBox Environment
11/26 Introduction Example Component Parts UML Notation Selecting Juggler
12/26 Introduction Example Component Parts UML Notation 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 • BeanBoxrecognizes that Juggler is a Component, and displays an image of an instance. • Jugglerlistens for several kinds of events
13/26 Introduction Example Component Parts UML Notation Observations on Juggler Source Code 2 • BeanBoxrecognizes that Juggler implements the Runnable interface, and automatically executes its run() • Juggleroperates 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 );
14/26 Introduction Example Component Parts UML Notation 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 intproperty, and allows it to be set.
15/26 Introduction Example Component Parts UML Notation Observations on Juggler Source Code 2 KEY CONCEPT Design Goal At: Reusability • 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( booleandmode ) ….. We want to construct and re-use a Juggler instance connected to Start / Stop buttons.
16/26 Introduction Example Component Parts UML Notation Adding behavior KEY CONCEPT Design Goal At: Reusability Causing ExplicitButton Press to call stopJuggling() on Juggler We want the functionality and event sensitivity of a Bean to be available in any context.
Properties Methods in the form of methods, published in interfaces Reactions to Events Ability to provide information about themselves Set of classes providing interfaces Manifest See below 17/26 Introduction Example Component Parts UML Notation The Parts of a Component 10.3 Referred as PME model Properties/Methods/Events
18/26 Introduction Example Component Parts UML Notation Manifests KEY CONCEPT The Aspects of a Component • 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.
19/26 Introduction Example Component Parts UML Notation Introspection Runtime Java Information Includes
20/26 Introduction Example Component Parts UML Notation UML Notation for Components 10.4 interfaces supported components
21/26 Introduction Example Component Parts UML Notation Phases of a Component’s 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
22/26 Introduction Example Component Parts UML Notation 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
23/26 Introduction Example Component Parts UML Notation 2- Instance Creation Time Create instance Store instance component instance component Compiled collection of classes Component environment Storage
24/26 Introduction Example Component Parts UML Notation 3- Assembly Time Related instances Instance creation and connection Components Storage
25/26 Introduction Example Component Parts UML Notation 4- Deployment Time KEY CONCEPT The Lifecycle of a Component Execution environment Storage Select, design, code source, instantiate, combine instances, deploy in applications, execute. component Compiled classes of the application Complete application
26/26 Introduction Example Component Parts UML Notation 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