COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of...

66
COP 4009 7 th Lecture October 31, 2005 COP 4009 COP 4009 Component-Based Software Engineering Component-Based Software Engineering The Art of Design The Art of Design Fall 2005 Instructor: Masoud Sadjadi http://www.cs.fiu.edu/~sadjadi/Teaching/

description

Seventh Lecture on October 31, 2005COP-4009: Component-Based Software Engineering 3 Agenda  Motivation  System Design Overview  Design Goals  System Decomposition  Summary

Transcript of COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of...

Page 1: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

COP 4009 7th Lecture October 31, 2005

COP 4009 COP 4009 Component-Based Software EngineeringComponent-Based Software Engineering

The Art of DesignThe Art of Design

Fall 2005Instructor: Masoud Sadjadi

http://www.cs.fiu.edu/~sadjadi/Teaching/

Page 2: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 2COP-4009: Component-Based Software Engineering

AcknowledgementsAcknowledgements Dr. George T. Heineman

– This course is based on the “CS 509 Design of Software Systems - Spring 2005” by Dr. Heineman with some adjustments to become appropriate for undergraduate students. Dr. Heineman has generously offered his course material (including the slides) and his help during preparation of this course. I am very grateful to him.

– The original slides and the course material can be found at: http://www.cs.wpi.edu/~heineman/html/teaching_/CS509/index.html

Dr. William Councill and other authors of the main textbook

Dr. Clemens Szyperski

Drs. Betty Cheng, Peter Clarke, Bernd Bruegge, and Allen Dutoit

Page 3: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 3COP-4009: Component-Based Software Engineering

AgendaAgenda Motivation System Design Overview Design Goals System Decomposition Summary

Page 4: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 4COP-4009: Component-Based Software Engineering

MotivationMotivation“There are two ways of constructing a software

design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies.”

- C.A.R. Hoare

Page 5: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 5COP-4009: Component-Based Software Engineering

Why is Design so Difficult?Why is Design so Difficult? Analysis: Focuses on the application domain Design: Focuses on the solution domain

– Design knowledge is a moving target– The reasons for design decisions are changing very rapidly

Halftime knowledge in software engineering: About 3-5 years What I teach today will be out of date in 3 years Cost of hardware rapidly sinking

“Design window”: – Time in which design decisions have to be made

Technique– Time-boxed prototyping

Page 6: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 6COP-4009: Component-Based Software Engineering

The Purpose of System DesignThe Purpose of System Design Bridging the gap between

desired and existing system in a manageable way

Use Divide and Conquer– We model the new system to

be developed as a set of subsystems

Problem

Existing System

NewSystem

Page 7: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 7COP-4009: Component-Based Software Engineering

AgendaAgenda Motivation System Design Overview Design Goals System Decomposition Summary

Page 8: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 8COP-4009: Component-Based Software Engineering

System DesignSystem Design

System Design

2. System

Layers/PartitionsCohesion/Coupling

5. Data

1. Design Goals Definition

Trade-offs

4. Hardware/

Special purpose

Software

Buy or Build Trade-offAllocationConnectivity

3. Concurrency

Data structure

Persistent ObjectsFilesDatabases

ManagementAccess controlSecurity

6. Global Resource Handling

8. BoundaryConditions

InitializationTerminationFailure

Decomposition

Mapping

7. Software Control

Identification of Threads

MonolithicEvent-DrivenThreadsConc. Processes

Page 9: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 9COP-4009: Component-Based Software Engineering

OverviewOverview System Design I (this lecture)

– 0. Overview of System Design– 1. Design Goals– 2. Subsystem Decomposition

System Design II: Addressing Design Goals (next lecture)– 3. Concurrency– 4. Hardware/Software Mapping– 5. Persistent Data Management– 6. Global Resource Handling and Access Control– 7. Software Control– 8. Boundary Conditions

Page 10: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 10COP-4009: Component-Based Software Engineering

AgendaAgenda Motivation System Design Overview Design Goals System Decomposition Summary

Page 11: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 11COP-4009: Component-Based Software Engineering

List of Design GoalsList of Design Goals Reliability Modifiability Maintainability Understandability Adaptability Reusability Efficiency Portability Traceability of requirements Fault tolerance Backward-compatibility Cost-effectiveness Robustness High-performance

Good documentation Well-defined interfaces User-friendliness Reuse of components Rapid development Minimum # of errors Readability Ease of learning Ease of remembering Ease of use Increased productivity Low-cost Flexibility

Page 12: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 12COP-4009: Component-Based Software Engineering

Relationship Between Design Relationship Between Design GoalsGoals

Reliability

Low cost Increased ProductivityBackward-CompatibilityTraceability of requirementsRapid developmentFlexibility

Client End User

PortabilityGood Documentation

RuntimeEfficiency

Developer

Minimum # of errorsModifiability, ReadabilityReusability, AdaptabilityWell-defined interfaces

FunctionalityUser-friendlinessEase of UseEase of learningFault tolerantRobustness

NielsonUsability EngineeringMMK, HCIRubinTask Analysis

Page 13: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 13COP-4009: Component-Based Software Engineering

Typical Design Trade-offsTypical Design Trade-offs Functionality vs. Usability Cost vs. Robustness Efficiency vs. Portability Rapid development vs. Functionality Cost vs. Reusability Backward Compatibility vs. Readability

Page 14: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 14COP-4009: Component-Based Software Engineering

AgendaAgenda Motivation System Design Overview Design Goals System Decomposition

– Component Modeling– Documentation for Reuse– System Architecture

Summary

Page 15: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 15COP-4009: Component-Based Software Engineering

Modeling ComponentsModeling Components Bad news:

– To date, there is no standard for modeling components!

Good news:– We have UML! We use UML

To model the design and implementation representations of components.

– To document components for reuse.

– UML is becoming more CBSE-aware UML subsystem (realize multiple interfaces) UML interfaces (realized by multiple subsystems)

Page 16: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 16COP-4009: Component-Based Software Engineering

Why no large-scale reuse Why no large-scale reuse yet?!yet?!

Reuse efforts at implementation level– Technology changes rapidly and standards are only emerging.– No design-level reuse!

Appropriate components are too hard to find Once found, the documentation is often inadequate Implementation may differ in execution of key interface

responsibilities– If used in a different context, it may not perform as well.

Goal:– To specify the entire realization of a component in such a way that

the generation of a particular implementation style can be done automatically.

– Distinction between the detailed design and its implementation.

Page 17: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 17COP-4009: Component-Based Software Engineering

Solution: Using UML to ModelSolution: Using UML to Model CBSE Promises:

– Complexity Management– Encapsulation– Separation of Concerns– Reuse

UML satisfies these promises!– It can model a component’s design and implementation– It can be used as the basis for its reuse documentation

Page 18: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 18COP-4009: Component-Based Software Engineering

Aspects of ComponentsAspects of Components Logical aspect

– Concerned with its logical abstraction– Its relationship with other logical elements– Its assigned responsibilities

Physical (implementation) aspect– What elements are inside the component– How they realize the contract (interface) of a component– What is the relationship among the elements inside a component– What are the internal and external interactions

Page 19: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 19COP-4009: Component-Based Software Engineering

Modeling Logical Aspect with Modeling Logical Aspect with UMLUML

UML Subsystems– A design view of the component

A UML Subsystem is a subtype of a UML Package A subsystem is modeled as

– A package annotated with <<subsystem>> An interface is modeled as

– A circle– A full rectangle with a small circle in the right top corner– A full rectangle annotated with <<interface>>

A subsystem is related to the interfaces it realizes – via the realization relationship.

Page 20: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 20COP-4009: Component-Based Software Engineering

Subsystems & InterfacesSubsystems & Interfaces

«interface»IClipboard

+ boolean insert (IItem I)+ IItem retrieve ()

«subsystem»Clipboard

«subsystem»Clipboard

IClipboard

realization

Page 21: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 21COP-4009: Component-Based Software Engineering

Subsystems and ServicesSubsystems and Services Subsystem (UML: Package)

– Collection of classes, associations, operations, events and constraints that are interrelated

– Seed for subsystems: UML Objects and Classes.

(Subsystem) Service: – Group of operations provided by the subsystem – Seed for services: Subsystem use cases

Service is specified by Subsystem interface:– Specifies interaction and information flow from/to subsystem

boundaries, but not inside the subsystem. – Should be well-defined and small. – Often called API: Application programmer’s interface, but this term

should used during implementation, not during System Design

Page 22: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 22COP-4009: Component-Based Software Engineering

Services and Subsystem Services and Subsystem InterfacesInterfaces

Service: A set of related operations that share a common purpose– Notification subsystem service:

LookupChannel() SubscribeToChannel() SendNotice() UnscubscribeFromChannel()

– Services are defined in System Design

Subsystem Interface: Set of fully typed related operations.– Subsystem Interfaces are defined in Object Design– Also called application programmer interface (API)

Page 23: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 23COP-4009: Component-Based Software Engineering

Modeling Physical Aspect with Modeling Physical Aspect with UMLUML

For each realized interface– UML <<realization>> collaborations can be used– It shows how the subsystem elements interact to satisfy the

interface contract.– Inside the collaboration UML diagrams are used to document both

the structure and behavioral aspects of the solution: Class Diagrams

– Showing major relationships between subsystem elements – Showing major relationships between other subsystems

Statechart Diagrams– Showing important behavioral aspects of a subsystem as a whole

Interaction Diagrams (Sequence and Collaboration Diagrams)– Showing how the subsystem elements implement the major interface

operations

Page 24: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 24COP-4009: Component-Based Software Engineering

The UML CollaborationThe UML Collaboration Used to document a “solution to a problem”

Similar to Package– Allows grouping together a set of UML diagrams in order to

document how their design satisfies key requirements.– May import and use elements from other namespaces in the model

Unlike a Package– May not own any elements except for a set of placeholders

Page 25: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 25COP-4009: Component-Based Software Engineering

Internal Structure ViewInternal Structure View

«interface» IClipboard

+ IItem retrieve ()+ IItem retrieveNth (int n)+ IItem retrieve (IDataType type)+ IItem retrieveNth (int n, IDataType type)+ void clear ()+ void insert (IItem item)+ Enumeration types ()+ IItem newItemInstance (IDataType t, Object o)+ IDataType newDataTypeInstance (String s)

«subsystem»Clipboard

«interface» IClipboardGUI

+ setAccessor (IClipboardAccessor i)+ showClipboard (boolean b)

«interface» IClipboardAccessor

+ requestClear()+ requestCopy()+ requestPaste()+ requestPasteAll() requires

???

Page 26: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 26COP-4009: Component-Based Software Engineering

Object Sequence Diagram Object Sequence Diagram (copy)(copy)

aClipboardClient :Clipboard

:IClipboardAccessor

1. IDataType newDataTypeInstance (String s)

2. IItem newItemInstance (IDataType t, Object o)

3. Insert (IItem item)

Page 27: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 27COP-4009: Component-Based Software Engineering

Object Sequence Diagram Object Sequence Diagram (paste)(paste)

aClipboardClient :Clipboard

:IClipboardAccessor

1. IItem retrieve ()

Page 28: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 28COP-4009: Component-Based Software Engineering

Object Sequence DiagramObject Sequence Diagram

aClipboardClient :Clipboard

:IClipboardAccessor

:ClipboardGUI

1. void showClipboard (true)1.1 activateFrame (true)

2. RequestPaste ()

2.1 IItem retrieve ()

show

paste

Page 29: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 29COP-4009: Component-Based Software Engineering

Object Sequence DiagramObject Sequence Diagram Identify interactions at design level

– ordering of method invocations– dependencies (causal and data)

Interface associations– generic usage of interface

Component association– specific usage of interface

Page 30: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 30COP-4009: Component-Based Software Engineering

Object Collaboration DiagramObject Collaboration Diagram More compact representation

:Ca :Cb

:Cc

1. MethodInvocation ()4. somethingElse()

2. MethodY3. MethodZ

Page 31: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 31COP-4009: Component-Based Software Engineering

Modeling the Implementation Modeling the Implementation Rep.Rep.

Defines how its logical representation is implemented in the chosen environment.

It defines the mapping between subsystems and components in the chosen environment.

We use UML Components for this– Different UML component stereotypes can be used to distinguish

different types of implementation elements <<.CPP>>, <<.H>>, <<.EXE>>, <<.DLL>>, <<.DOC>>, etc.

– A UML component is the physical realization of one or more UML subsystems.

– Avoid it if there is an obvious mapping.

Page 32: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 32COP-4009: Component-Based Software Engineering

Mapping subsystem to Mapping subsystem to componentcomponent

The transformation from design subsystems to components is affected by– The chosen implementation language– The chosen component model, if any– How the components are to be deployed– The source of the component

Bought Developed Open source

Page 33: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 33COP-4009: Component-Based Software Engineering

Modeling of Implementation Modeling of Implementation Rep.Rep.

Aspects to be considered in – Development

How the component is developed as opposed to being bought or reused

Modeled using work product components– Source code files, data files, build files, and all other intermediate artifacts.– It enables the visual representation of the compilation dependencies.

– Deployment The final form in which the component will be deployed. Modeled using deployment components

– Depicts the elements that need to be delivered as part of the particular release of a software.

– They end up on the nodes of the physical system at runtime.– Executables, shared libraries, non-executable resources.

Page 34: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 34COP-4009: Component-Based Software Engineering

Component MappingComponent Mapping Development: Work Product Components

– Mapping from a work product component to a subsystem element.

Deployment: Deployment Components– Mapping from a deployment component to a subsystem.

CourseCatalogConnector Main (from CourseCatalog)

+ getCourses()+ getSections()

«subsystem»CourseCatalog

ICourseCatalog

<<.CPP>> CourseCatalog

ConnectorMain

<<trace>>

<<.EXE>> CourseCatalog

Connector

<<trace>>ICourseCatalog

Page 35: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 35COP-4009: Component-Based Software Engineering

Component MappingComponent Mapping Deployment Component to Work Product Component

Mapping

<<.CPP>> CourseCatalog

ConnectorMain

<<.EXE>> CourseCatalog

Connector

Page 36: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 36COP-4009: Component-Based Software Engineering

AgendaAgenda Motivation System Design Overview Design Goals System Decomposition

– Component Modeling– Documentation for Reuse– System Architecture

Summary

Page 37: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 37COP-4009: Component-Based Software Engineering

Documentation for ReuseDocumentation for Reuse It is difficult to find appropriate components It is even more difficult when you try to reuse them Why?

– Inadequate documentations!

Document the Contractual Semantics of the components, not its actual implementation.– This way you do not violate the principle of encapsulation

Page 38: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 38COP-4009: Component-Based Software Engineering

Steps in DocumentationSteps in Documentation Identify and extract the primary artifacts

– Deployment components – Definitions of any realized interfaces (incoming interfaces)– Required interfaces (outgoing interfaces)– The key properties of the components.

Identify and extract all related/secondary artifacts– The supplementary assets that help describe the context in which a

component was designed– They are important for proper reuse of components.– Component’s reuse context:

Related use case realizations, preconditions and postconditions, quality factors, contextual information

– Other secondary artifacts: Logical representations (UML Subsystems, their associated interface

realizations, any major structural elements) The set of all related work products, if the component was developed.

Page 39: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 39COP-4009: Component-Based Software Engineering

Steps in DocumentationSteps in Documentation Document the internal component functionality

– Use UML Collaborations One UML <<realization>> collaboration for each interface realized by

the subsystem or component. Document and categorize the external component

functionality– User’s manual for components can be UML Collaborations.– Informally use class diagrams to show the interfaces in the

accompanying context and interaction diagrams that are descriptive rather than rigorous.

Parameterize any dependency if necessary Catalogue the component

– A searchable catalogue entry for the component using all the above information should be created.

Page 40: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 40COP-4009: Component-Based Software Engineering

Documentation GuidelinesDocumentation Guidelines Component Documentation Guidelines (P. 255)

– What the component is and does– Run-time characteristics– Constraints and limitations– Requirements from the environment to operate– Instructions for reuse– How the component fulfills its responsibilities

Interface Documentation Guidelines (P. 256)– Interface name– Interface description– Operation definition– Interface documentation: How the operations are used– Test Documentation

Page 41: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 41COP-4009: Component-Based Software Engineering

AgendaAgenda Motivation System Design Overview Design Goals System Decomposition

– Component Modeling– Documentation for Reuse– System Architecture

Summary

Page 42: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 42COP-4009: Component-Based Software Engineering

Choosing SubsystemsChoosing Subsystems Criteria for subsystem selection: Most of the interaction

should be within subsystems, rather than across subsystem boundaries (High cohesion).– Does one subsystem always call the other for the service?– Which of the subsystems call each other for service?

Primary Question: – What kind of service is provided by the subsystems (subsystem

interface)? Secondary Question:

– Can the subsystems be hierarchically ordered (layers)? What kind of model is good for describing layers and

partitions?

Page 43: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 43COP-4009: Component-Based Software Engineering

From Analysis to DesignFrom Analysis to Design Cohesion

– Logical interaction with a design unit BAD Coincidental Logical Temporal Procedural Communicational GOOD Functional GOOD Informational

Coupling– Physical interactions between design units

BAD Common Control IDEAL Data

Page 44: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 44COP-4009: Component-Based Software Engineering

Coupling and CohesionCoupling and Cohesion Goal: Reduction of complexity while change occurs Cohesion measures the dependence among classes

– High cohesion: The classes in the subsystem perform similar tasks and are related to each other (via associations)

– Low cohesion: Lots of miscellaneous and auxiliary classes, no associations Coupling measures dependencies between subsystems

– High coupling: Changes to one subsystem will have high impact on the other subsystem (change of model, massive recompilation, etc.)

– Low coupling: A change in one subsystem does not affect any other subsystem

Subsystems should have as maximum cohesion and minimum coupling as possible:– How can we achieve high cohesion?– How can we achieve loose coupling?

Page 45: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 45COP-4009: Component-Based Software Engineering

Partitions and LayersPartitions and LayersPartitioning and layering are techniques to achieve low

coupling.A large system is usually decomposed into subsystems using

both, layers and partitions. Partitions vertically divide a system into several

independent (or weakly-coupled) subsystems that provide services on the same level of abstraction.

A layer is a subsystem that provides subsystem services to a higher layers (level of abstraction)– A layer can only depend on lower layers– A layer has no knowledge of higher layers

Page 46: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 46COP-4009: Component-Based Software Engineering

Subsystem Decomposition into Subsystem Decomposition into LayersLayers

Subsystem Decomposition Heuristics: No more than 7+/-2 subsystems

– More subsystems increase cohesion but also complexity (more services)

No more than 4+/-2 layers, use 3 layers (good)

F:SubsystemE:Subsystem G:Subsystem

D:SubsystemC:SubsystemB:Subsystem

A: Subsystem Layer 1

Layer 2

Layer 3

Page 47: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 47COP-4009: Component-Based Software Engineering

Relationships between Relationships between SubsystemsSubsystems

Layer relationship– Layer A “Calls” Layer B (runtime)– Layer A “Depends on” Layer B (“make” dependency, compile time)

Partition relationship– The subsystem have mutual but not deep knowledge about each

other– Partition A “Calls” partition B and partition B “Calls” partition A

Page 48: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 48COP-4009: Component-Based Software Engineering

Layering Example: Virtual Layering Example: Virtual MachineMachine

Dijkstra: T.H.E. operating system (1965)– A system should be developed by an ordered set of virtual

machines, each built in terms of the ones below it.

VM4

VM3

VM2

VM1

Problem

Existing System

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Page 49: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 49COP-4009: Component-Based Software Engineering

Virtual MachineVirtual Machine A virtual machine is an abstraction

– It provides a set of attributes and operations. A virtual machine is a subsystem

– It is connected to higher and lower level virtual machines by "provides services for" associations.

Virtual machines can implement two types of software architecture– Open Architectures.– Closed Architectures.

Page 50: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 50COP-4009: Component-Based Software Engineering

Closed ArchitectureClosed Architecture Also called Opaque Layering Any layer can only invoke operations from the immediate

layer below Design goal: High maintainability, flexibility

VM4

VM3

VM2

VM1

Problem

Existing System

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Page 51: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 51COP-4009: Component-Based Software Engineering

Open ArchitectureOpen Architecture Also called Transparent Layering Any layer can invoke operations from any layers below Design goal: Runtime efficiency

VM4

VM3

VM2

VM1

Problem

Existing System

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Classattropr

Page 52: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 52COP-4009: Component-Based Software Engineering

Properties of Layered Properties of Layered SystemsSystems

Layered systems are hierarchical. Hierarchy reduces complexity (low coupling). Closed architectures are more portable. Open architectures are more efficient. If a subsystem is a layer, it is often called a virtual

machine. Chicken-and egg problem

– Example: Debugger opening the symbol table when the file system needs to be debugged

G: Op. System

D: File System

A: Debugger

Page 53: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 53COP-4009: Component-Based Software Engineering

Software Architectural StylesSoftware Architectural Styles Subsystem decomposition

– Identification of subsystems, services, and their relationship to each other.

Specification of the system decomposition is critical.

Patterns for software architecture– Repository– Model/View/Controller – Client/Server– Peer-To-Peer– Three-Tier– Four-Tier– Pipes and Filters

Page 54: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 54COP-4009: Component-Based Software Engineering

Repository Architectural StyleRepository Architectural Style Subsystems access and modify data from a single data

structure Subsystems are loosely coupled (interact only through the

repository) Control flow is dictated by central repository (triggers) or by

the subsystems (locks, synchronization primitives)

Subsystem

Repository

createData()setData()getData()searchData()

Page 55: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 55COP-4009: Component-Based Software Engineering

ExamplesExamples

LexicalAnalyzer

SyntacticAnalyzerSemanticAnalyzer

CodeGenerator

Compiler

SyntacticEditor

ParseTree SymbolTable

Repository

SourceLevelDebugger

Optimizer

Page 56: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 56COP-4009: Component-Based Software Engineering

Model/View/ControllerModel/View/Controller Subsystems

– Model subsystem Responsible for application domain knowledge

– View subsystem Responsible for displaying application domain objects

– Controller subsystem Responsible for sequence of interactions.

MVC and Repository Architecture– is a special case of a repository architecture

Controller

Model

subscribernotifier

initiator

*

repository1

1

*

View

Page 57: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 57COP-4009: Component-Based Software Engineering

Client/Server Architectural Client/Server Architectural StyleStyle

One or many servers provides services to instances of subsystems, called clients.

Client calls on the server, which performs some service and returns the result – Client knows the interface of the server (its service)– Server does not need to know the interface of the client

Response in general immediately Users interact only with the client

Client

Server

service1()service2()

serviceN()…

**requester provider

Page 58: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 58COP-4009: Component-Based Software Engineering

Client/Server Architectural Client/Server Architectural StyleStyle

Often used in database systems:– Front-end: User application (client)– Back end: Database access and manipulation (server)

Functions performed by client:– Customized user interface– Front-end processing of data– Initiation of server remote procedure calls– Access to database server across the network

Functions performed by the database server:– Centralized data management– Data integrity and database consistency– Database security– Concurrent operations (multiple user access)– Centralized processing (for example archiving)

Page 59: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 59COP-4009: Component-Based Software Engineering

Design Goals for Client/Server Design Goals for Client/Server SystemsSystems

Service Portability– Server can be installed on a variety of machines and operating systems and

functions in a variety of networking environments Transparency, Location-Transparency

– The server might itself be distributed (why?), but should provide a single "logical" service to the user

Performance– Client should be customized for interactive display-intensive tasks– Server should provide CPU-intensive operations

Scalability– Server should have spare capacity to handle larger number of clients

Flexibility– The system should be usable for a variety of user interfaces and end devices (e.g.,

wearable computer and desktop) Reliability

– System should survive node or communication link problems

Page 60: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 60COP-4009: Component-Based Software Engineering

Problems with Client/ServerProblems with Client/Server Peer-to-peer communication is often needed

Example: Database receives queries from application but also sends notifications to application when data have changed

Page 61: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 61COP-4009: Component-Based Software Engineering

Peer-to-Peer Architectural Peer-to-Peer Architectural StyleStyle

Generalization of Client/Server Architecture Clients can be servers and servers can be clients More difficult because of possibility of deadlocks

Peer

service1()service2()

serviceN()…

requester

provider

*

*

application1:DBUser

database:DBMS

application2:DBUser

1. updateData

2. changeNotification

Page 62: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 62COP-4009: Component-Based Software Engineering

Three-tier architectural styleThree-tier architectural style

Interface

Application Logic

Storage

Connection

Form

Query

Page 63: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 63COP-4009: Component-Based Software Engineering

Four tier architectural styleFour tier architectural style

Presentation Server

Application Logic

Storage

Connection

Form

Query

Presentation Client WebBrowser

Page 64: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 64COP-4009: Component-Based Software Engineering

Pipe and filter architectural Pipe and filter architectural stylestyle

Pipeinput output

output input* 1

* 1Filter

% ps auxwww | grep dutoit | sort | more

ps grep sort more

Page 65: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 65COP-4009: Component-Based Software Engineering

AgendaAgenda Motivation System Design Overview Design Goals System Decomposition Summary

Page 66: COP 4009 7 th Lecture October 31, 2005 COP 4009 Component-Based Software Engineering The Art of Design Fall 2005 Instructor: Masoud Sadjadi

Seventh Lecture on October 31, 2005 66COP-4009: Component-Based Software Engineering

SummarySummary System Design

– Reduces the gap between requirements and the (virtual) machine– Decomposes the overall system into manageable parts

Design Goals Definition– Describes and prioritizes the qualities that are important for the

system– Defines the value system against which options are evaluated

Subsystem Decomposition– Results into a set of loosely dependent parts which make up the

system– Basically we identify and model our components.