software designchate/2110634/02-sw-design.pdf · software architecture software design 17 . 18...

54
Software Design

Upload: others

Post on 26-Jun-2020

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Software Design

Page 2: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Software Design

• A software design is a precise description of a system, using variety of different perspective.

Software design are complicated, therefore, they must be modeled.

Software Design 2

Page 3: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Modeling as a design technique

• Similar to an architects blueprint

• A model is an abstraction of the underlying problem

• Designs are too complicated to develop from scratch

• Good designs tend to be build using models… – Abstract different views of the system

– Build models using precise notations (e.g., UML)

– Verify that the models satisfy the requirements

– Gradually add details to transform the models into the design

Software Design 3

Page 4: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Modeling as a design technique

Software Design 4

Page 5: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Modeling as a design technique - improved

Software Design 5

Page 6: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

UML – a modeling notation

Software Design 6

Page 7: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Software Architecture

• According to Shaw and Garlan [1]

– The Software Architecture of a system consists of a description of the system elements, interactions between the system elements, patterns that guide the system elements, and constraints on the relationships between system elements.

• Its a more abstract view of the design

• Its helpful for communication and complexity management

Software Design 7

Page 8: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Software Architecture

• The software architecture of a program or computing system is a depiction of the system that aids in the understanding of how the system will behave.

• serves as the blueprint for both the system and the project developing it,

• defining the work assignments that must be carried out • primary carrier of system qualities such as

– performance, modifiability, and security, none of which can be achieved without a unifying architectural vision.

• Architecture is an artifact for early analysis to make sure that a design approach will yield an acceptable system.

Software Design 8

http://www.sei.cmu.edu/architecture/

Page 9: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

The Software Architecture “Stack”

Software Design 9

Page 10: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

The Software Architecture “Stack”

Software Design 10

Page 11: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Design Methodologies

Software Design 11

Page 12: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Jumpstart Design

Software Design 12

templates, patterns, frameworks, … from scratch is difficult

Page 13: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Spring Framework

Software Design 13

Page 14: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Software Design 14

Page 15: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Improving Existing Designs

• Refactoring

– technique for restructuring an existing body of code, altering its internal structure without changing its external behavior

Software Design 15

Page 16: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Design Patterns & Anti Patterns

• a formal way of documenting a solution to a design problem

• Anti patterns – negative solutions

Software Design 16

Page 17: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

SOFTWARE ARCHITECTURE

17 Software Design

Page 18: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

18

Software Decomposition

Software Decomposition

– Subsystem

– Partition

• Software Design Quality

– Coupling

– Cohesion

Software Design

Page 19: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

19

What is Subsystem

• Collection of software elements such as software modules and their relations

• The subsystem boundary is defined explicitly

• The dependency relations among subsystems are defined

• Using “Partition” and “Layer” techniques to minimize the dependency relations

Software Design

Page 20: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

20

Sample of Subsystem Decomposition

Modeling

Authoring

Workorder Repair

Inspection

Augmented

Reality

Workflow

Software Design

Page 21: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

21

Partitions and Layers

• Partitioning 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

Software Design

Page 22: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

22

F:SubsystemE:Subsystem G:Subsystem

D:SubsystemC:SubsystemB:Subsystem

A: Subsystem Layer 1

Layer 2

Layer 3

Subsystem Decomposition into Layers

• 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)

Software Design

Page 23: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Closed Architecture (Opaque Layering)

• Any layer can only invoke operations from the immediate layer below

• Design goal: High maintainability, flexibility

Software Design 23

Page 24: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Open Architecture (Transparent Layering)

• Any layer can invoke operations from any layers below

• Design goal: Runtime efficiency

Software Design 24

Page 25: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Coupling and Cohesion

• Goal: Reduction of complexity while change occurs

• Cohesion measures the dependence among modules –High cohesion: The modules in the subsystem

perform similar tasks and are related to each other (via associations)

–Low cohesion: Lots of miscellaneous and auxiliary modules, no associations

Software Design 25

Page 26: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Coupling and Cohesion

• 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?

Software Design 26

Page 27: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Sample of Cohesion

Software Design 27

Subsystem A

Subsystem B

M1

M4

M2

M5

M3 M1

M4

M2

M5

M3

High Cohesion Low Cohesion

Page 28: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

28

Sample of Coupling

Subsystem A

M1 M2

Subsystem B

M3 M4

Subsystem A

M1 M2

Subsystem B

M3 M4

High Coupling Low Coupling Software Design

Page 29: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Software Architecture Design

• Software Architectural Styles

– Client/Server

– Peer-to-Peer

– Repository

– Model/View/Control

– Pipe and Filter

Software Design 29

Page 30: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Software 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 – Client/Server

– Peer-To-Peer

– Repository

– Model/View/Controller

– Pipes and Filters

Software Design 30

Page 31: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Client/Server Architectural Style

• 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

Software Design 31

Client

Server

service1()service2()

serviceN()…

**requester provider

Page 32: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Client/Server Architectural Style

• 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)

Software Design 32

Page 33: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Design Goals for Client/Server Systems

• 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 (eg. WAP Handy, wearable computer, desktop) • Reliability

– System should survive node or communication link problems

Software Design 33

Page 34: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Problems with Client/Server Architectural Styles

• Layered systems do not provide peer-to-peer communication

• Peer-to-peer communication is often needed

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

Software Design 34

Page 35: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Peer-to-Peer Architectural Style

• Generalization of Client/Server Architecture

• Clients can be servers and servers can be clients

• More difficult because of possibility of deadlocks

Software Design 35

Peer

service1()service2()

serviceN()…

requester

provider

*

*

Page 36: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Model/View/Controller

• Subsystems are classified into 3 different types – Model subsystem: Responsible for application domain knowledge – View subsystem: Responsible for displaying application domain

objects to the user – Controller subsystem: Responsible for sequence of interactions with

the user and notifying views of changes in the model.

• MVC is a special case of a repository architecture: – Model subsystem implements the central datastructure, the Controller

subsystem explicitly dictate the control flow

Software Design 36

Page 37: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Repository Architectural Style (Blackboard Architecture)

• 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)

Software Design 37

Subsystem

Repository

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

Page 38: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Pipe and Filter

• Subsystems process data received from a set of inputs and send results to other subsystems via a set of outputs

• The subsystems are called “Filters”

• The associations between the subsystems are called “Pipes”

Software Design 38

Sub1 Sub4

Sub3

Sub2 Sub5 Filter

Pipe

Page 39: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Sample of Subsystem Decomposition

Software Design 39

<<Subsystem>>

Purchase Order

<<Subsystem>>

Inventory

Verification

<<Subsystem>>

Invoice

<<Subsystem>>

Goods Receive

<<Subsystem>>

Budgeting

<<Subsystem>>

Payment

<<Subsystem>>

Vendor

Maintenance

Decomposing a set of Subsystems

Page 40: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

40

Sample of Subsystem Decomposition

<<Subsystem>>

Purchase Order

<<Subsystem>>

Inventory

Verification

<<Subsystem>>

Invoice

<<Subsystem>>

Goods Receive

<<Subsystem>>

Budgeting

<<Subsystem>>

Payment

<<Subsystem>>

Vendor

Maintenance

Define the dependency among subsystems

Software Design

Page 41: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

41

Sample of Subsystem with Interfaces

<<Subsystem>>

Purchase Order

<<Subsystem>>

Inventory

Verification

<<Subsystem>>

Invoice

<<Subsystem>>

Goods Receive

<<Subsystem>>

Budgeting <<Subsystem>>

Payment

<<Subsystem>>

Vendor

Maintenance

Decomposing a set of Subsystems

IPO2 IPO1

IIV1

IP1

IGR1

Software Design

Page 42: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

42

Sample of Hierarchy of Subsystems

<<Subsystem>>

Purchase

Order <<Subsystem>>

Inventory

Verification

<<Subsystem>>

Goods Receive

<<Subsystem>>

Budgeting

<<Subsystem>>

Payment

<<Subsystem>>

Vendor

Maintenance

<<Subsystem>>

<<Subsystem>>

Inventory

Purchasing

IIV1

IGR1 IP1

IPO2 IPO1

IX1

Finance

<<Subsystem>>

Bank System

<<Subsystem>>

Invoice

Software Design

Page 43: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

43

Sample of Hierarchy of Subsystems (with Information Hiding)

<<Subsystem>>

<<Subsystem>>

Inventory

Purchasing

IIV1

IGR1 IP1

IPO2 IPO1

IX1

Finance

<<Subsystem>>

Bank System Software Design

Page 44: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

44

Typical Sale Component

<<Subsystem>>

Purchase

Order

<<Subsystem>>

Invoice

<<Subsystem>>

Vendor

Maintenance

<<Component>> Purchasing

IPO2 IPO1

1 Subsystem = 1 Component

<<Subsystem>>

Purchase

Order

<<Subsystem>>

Vendor

Maintenance

<<Subsystem>>

Purchasing

IPO2 IPO1

<<Subsystem>>

Invoice

Software Design

Page 45: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

45

Typical Sale Component (with Information Hiding)

<<Component>>

Purchasing

IPO2

IPO1 1 Subsystem = 1 Component

<<Subsystem>>

Purchase

Order

<<Subsystem>>

Vendor

Maintenance

<<Subsystem>>

Purchasing

IPO2 IPO1

<<Subsystem>>

Invoice

Software Design

Page 46: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

46

Typical Finance Component (with Information Hiding)

<<Subsystem>>

Budgeting

<<Subsystem>>

Payment

IP1

Finance

<<Subsystem>>

<<Component>>

Finance

IP1 1 Subsystem = 1 Component

Software Design

Page 47: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Typical Inventory Component (with Information Hiding)

Software Design 47

<<Component>>

Inventory

IX1 1 Subsystem = 1 Component <<Subsystem>>

Inventory

Verification

<<Subsystem>>

Goods Receive

<<Subsystem>>

Inventory

IIV1

IGR1

IX1

IIV1

IGR1

Page 48: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Sample of Hierarchy of Subsystems (with Information Hiding)

Software Design 48

<<Subsystem>>

<<Subsystem>>

Inventory

Purchasing

IIV1

IGR1 IP1

IPO2 IPO1

IX1

Finance

<<Subsystem>>

Bank System

Page 49: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Define a Component Diagram

Software Design 49

<<Component>>

Purchasing

IPO2

IPO1

<<Component>>

Finance

IP1

<<Component>>

Inventory

IX1

IIV1

IGR1

Page 50: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Deployment of Client-Server

Software Design 50

Application Server Client

<<Component>>

Sale

IPO2 IPO1

<<Component>>

Finance

IP1

<<Component>>

Inventory

IX1 IIV1

IGR1

Page 51: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Deployment of Web Application

Software Design 51

Client

<<Component>>

Web Server

Application Server

<<Component>>

Sale

IPO2 IPO1

<<Component>>

Finance

IP1

<<Component>>

Inventory

IX1 IIV1

IGR1

Page 52: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Tracing from Use Cases to Design

Software Design 52

Finance

Bank System

Check Available Budget

Prepare Payment

Check Credit Line

Officer

Page 53: Software Designchate/2110634/02-sw-design.pdf · SOFTWARE ARCHITECTURE Software Design 17 . 18 Software Decomposition Software Decomposition –Subsystem –Partition •Software

Tracing from Use Cases to Design

Software Design 53

<<Subsystem>>

Budgeting

<<Subsystem>>

Payment

IP1

Finance

<<Subsystem>>

Bank System

Check Available Budget

Prepare Payment

Check Credit Line

Officer

<<Realize>>

<<Realize>>

<<Realize>>