SWE 316: Software Design and Architecture

advertisement

SWE 316: Software Design and Architecture

Lecture 9

Architectures and Frameworks

To understand

… the goals of software architecture

… the meaning of “frameworks”

To be able to express a software architecture

… build frameworks

… complete a detailed design Ch 14

Adapted from Software Design: From

Programming to Architecture by Eric J.

Braude (Wiley 2003), with permission.

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

2/33

Requirements

Analysis

Process Phases Discussed in This Chapter

Framework

Design

Architecture Detailed Design

Key: x = main emphasis x = secondary emphasis

Implementation

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

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

3/33

The meaning of software architecture

What is a software architecture?

An architecture for a software application is its high level

design, enabling software engineers to gain understanding

An early stage of the system design process

It involves identifying major system components and their communications

Represents the link between specification and design processes

14.1

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

The meaning of software architecture

Architectural Design:

Establishing the overall structure of a software system

The design process for identifying the sub-systems making up a system and the framework for subsystem control and communication is architectural design

The output of this design process is a description of the software architecture

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

4/33

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

Software architecture

If the application is small (e.g. 10 classes) this decomposition may be considered as architecture.

5/33

In UML, If the application is big (hundreds of classes) we may group the classes into packages, so

Software architecture is a decomposition of application into a small number of packages (class collections)

Framework: a collection of classes applicable to multiple applications

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

An Architecture for a Video Store Application

Videos Rentals

6/33

Customers

Architecture is a high-level design

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

A Sequence for Obtaining The Class Model

0. Framework (some or all pre-existing)

7/33

More general

2. Create architecture

-- typically use framework

1. Create domain classes

-- from requirements analysis

3. Create remaining design classes

-- to complete the class model

-- possibly use framework

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

Models of OO Analysis and Design

To express requirements, architecture & detailed design

14.2

8/33

Use-case model

“Do this ...” e.g.*, engage foreign character

Class model

“with objects of these classes ...” e.g., with Engagement … classes

Target

Application

Data Flow model

“in this way ...” e.g., character scores flow from

… to …

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

State model

“reacting to these events ...” e.g., when foreign character enters

* Video game example

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

Deployment Environment

Three organizational dispositions to new systems

Integrate new systems into existing systems

Install support services for the first time

 Replace existing systems

Design deployment architecture

Type of infrastructure (i.e. Internet, Client/Server, Command)

Hardware environment (i.e. mainframe, mid-range servers, etc.)

Use existing infrastructure (i.e. single sign-on, networks, Internet access)

Architectural design issues for all organizations

Reliability

Security

Performance

Usability

Supportability

Object-Oriented Analysis and

Design with the Unified Process

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

9/33

10/33

Introduction Deployment Arch SW Architecture DataFlow Independent

Software Architecture

Design goals (review)

Correctness

Sufficiency

Robustness

Flexibility

Reusability

Efficiency

VM Repository Layered

14.3

Can be handled at lower levels of design

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

11/33

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

Modularization, cohesion, and coupling

It is not hard to write small programs

However, large applications are difficult to create

14.3.2

The principal problem 

complexity

Decomposing the problem (modularization) is an effective tool against complexity

The designer should form a clear mental model of how the application will work at a high level then

Develop a decomposition to match the mental model

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

Modularization, Cohesion, and Coupling

Goals of software decomposition: Cohesion & Coupling

12/33

Cohesion within a module is the degree to which communication takes place among the module’s elements

Coupling is the degree to which modules depend directly on other modules

Effective modularization is accomplished by

 maximizing cohesion and minimizing coupling

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent

Cohesion and Coupling

2

1

3

VM component

Repository Layered

Fig 14.16

4

13/33

High cohesion

 component

5 Bridge 6

Low coupling

Steel truss component

High coupling 

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent

Using Façade Pattern

VM Repository Layered

14/33

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

15/33

Architecture and Modularization of Encounter Video Game

EncounterGame

EncounterGame

«facade»

EncounterCharacters

EncounterCast

«facade» EncounterEnvironment

EncounterEnvironment

«facade»

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

Figure 14.19 Selecting a Basic Architecture

1. Develop a mental model of the application.

 as if it were a small application e.g., personal finance application ...

… “works by receiving money or paying out money, in any order, controlled through a user interface”.

2. Decompose into the required components.

 look for high cohesion & low coupling e.g., personal finance application ...

… decomposes into Assets, Sources, Suppliers, & Interface.

3. Repeat this process for the components.

4. Consider using Façade for each package.

16/33

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

Architectural design process

System structuring

The system is decomposed into several principal sub-systems and communications between these sub-systems are identified

17/33

Control modelling

A model of the control relationships between the different parts of the system is established

Modular decomposition

The identified sub-systems are decomposed into modules

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

Advantages of explicit architecture

Stakeholder communication

Architecture may be used as a focus of discussion by system stakeholders

18/33

Large-scale reuse

The architecture may be reusable across a range of systems

System analysis

Means that analysis of whether the system can meet its nonfunctional requirements is possible

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

19/33

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

A Classification of Software Architectures

Garlan & Shaw classification

Data Flow

Independent Components

Virtual Machines

Repositories

Layered

14.3.4

Reusability

We classify architectures so as to use them for several applications.

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent

1- Data Flow architecture

Data Flow

Data flowing between functional elements

VM

20/33

Repository Layered

14.3.4.1

Functional transformations process their inputs to produce outputs

May be referred to as a pipe and filter model (as in UNIX shell)

Variants of this approach are very common. When transformations are sequential, this is a batch sequential model which is extensively used in data processing systems

Not really suitable for interactive systems

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

Example of Data Flow Architecture and Corresponding Class Model

Requirement: Maintain wired financial transactions. account data account data deposit transaction result

Bank data account data deposit data analyze transaction transaction record

Architecture

(data flow)

Log

Comm withdrawal data transaction result bank address withdraw account data

A Class model:

Bank

1

Transaction analyze() record() *

Account withdraw() deposit()

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

21/33

22/33

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

2- Independent component architecture

Communicating processes executing in parallel occasionally communicating

Client-Server architectures:

Distributed system model which shows how data and processing is distributed across a range of components

Set of stand-alone servers which provide specific services such as printing, data management, etc.

Set of clients which call on these services

Network which allows clients to access servers

The Observer design pattern is of potential use in independent component architectures

14.3.4.2

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

Independent component architecture: an example, film and picture library

23/33

Client 1 Client 2 Client 3 Client 4

Wide-bandwidth network

Catalogue server

Catalogue

Video server

Film clip files

Software Engineering by Sommerville, 2004

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Picture server

Digitiz ed photographs

Hypertext server

Hypertext web

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

Independent component architecture: characteristics

Advantages

Makes effective use of networked systems. May require cheaper hardware

Easy to add new servers or upgrade existing servers

24/33

Disadvantages

No shared data model so sub-systems use different data organisation, data interchange may be inefficient

Redundant management in each server

No central register of names and services - it may be hard to find out what servers and services are available

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

25/33

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

4- Virtual machine architectures

A family of applications that are all expressible with a special-purpose high-level language

14.3.4.3

Interpreter + program in special-purpose language

Robotic control applications

The Interpreter design pattern is useful in implementing this architecture.

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

26/33

Introduction Deployment Arch SW Architecture DataFlow Independent VM

4- Repository architecture

Primarily built around large data collection

Repository Layered

14.3.4.4

App 1

App 2 database

App 3

Applications mostly storage,retrievals, and querying.

Sub-systems must exchange data. This may be done in two ways:

Shared data is held in a central database or repository and may be accessed by all sub-systems

Each sub-system maintains its own database and passes data explicitly to other sub-systems

When large amounts of data are to be shared, the repository model of sharing is most commonly used

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

27/33

Introduction Deployment Arch SW Architecture DataFlow Independent VM

5- Layered architecture

Subsystems each depending one-way on another subsystem

An architectural layer is a coherent collection of software artifacts

Each layer uses other layers and is used by other layers

Building applications layer by layer can greatly simplify the implementation process

Sometimes the Template design pattern can be applied.

Repository Layered

14.3.4.5

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent

Layered Architecture

3D engine layer

VM Repository Layered

«uses»

Role-playing game layer

Characters RolePlayingGame . . . .

«uses»

Layout

Application layer

Encounter

Characters

Encounter

Environment

. . . .

Encounter Game

28/33

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent

Requirement: Print monthly statements

VM Repository Layered

29/33

Layered Architecture

Example Using Aggregation

Architecture:

“uses”

Accounts Layer

Vendor-supplied Layer

Ajax bank common library Layer

Ajax bank printing Layer

Class model:

(relationships within packages and Vendor-supplied layer not shown)

Accounts

Account Customer

Ajax bank common library

AjaxLogo AjaxDisclaimer Regulations

Ajax bank printing

Printer Page

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Formatter

Introduction Deployment Arch SW Architecture DataFlow Independent

Coad-Yourdon Use of Packages

VM Repository Layered

30/33

Problem domain package

Interface package

Data management package

Task management package

Figure 14.25: Coad-Yourdon Use of Packages

Example

Java.applet

Java.awt

Java.lang

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent VM Repository Layered

Other architectures

Control models: concerned with the control flow between sub-systems.

Centralised control: one sub-system has overall responsibility for control and starts and stops other sub-systems.

 Example: Call-return model

Routine 1

Main program

Routine 2 Routine 3

31/33

Routine 1.1

Routine 1.2

Routine 3.1

Routine 3.2

Event-based control: each sub-system can respond to externally generated events from other sub-systems or the system’s environment

Example: Broadcast model

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Introduction Deployment Arch SW Architecture DataFlow Independent

Summary

What is a software architecture?

Architecture is a high-level design

VM Repository Layered

Complexity

Cohesion: is the degree to which communication takes place among the module’s elements (High cohesion is better)

Coupling: is the degree to which modules depend directly on other modules (Low coupling is better)

Classification of Software Architectures

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

32/33

Introduction Deployment Arch SW Architecture DataFlow Independent

Next Lecture

VM Repository Layered

33/33

Framework

14.4

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser

Download