SWE 621: Software Modeling and Architectural Design Lecture Notes On Software Design Lecture 1 - Introduction To Software Design
SWE 621: Software Modeling and Architectural Design Lecture Notes On Software Design Lecture 1 - Introduction To Software Design
Hassan Gomaa
Dept of Computer Science
George Mason University
Fairfax, VA
Copyright © 2011 Hassan Gomaa
All rights reserved. No part of this document may be reproduced in any form or
by any means, without the prior written permission of the author.
This electronic course material may not be distributed by e-mail or posted on any
other World Wide Web site without the prior written permission of the author.
1. Section I
Hassan Gomaa
Software Design
What is design?
noun: mentalt l plan,
l preliminary
li i sketch
k t h or outline
tli
verb: to conceive in the mind; to invent
What is software design?
As a product
Output of design process
As a process
Approach to doing design
• Design
– Form of problem solving
• Design as “wicked problem”
– Unlike an algorithm
• There is no one “correct” solution
• Tradeoffs in design
g
– E.g., Structure vs. performance
– Centralized vs. distributed
– Sequential vs. concurrent
• Architectural Design
– Structure system into components
– Define the interfaces between components
• Detailed Design
– Define internal logic
– Define internal data structures
Architectural Design
Overall description of software structure
Textual and Graphical
Specification of software components and their interfaces
Modules, classes
Detailed Design of each component
Internal logic
I
Internall data
d structures
Design decisions made
Design rationale
Traces to requirements
Software
So twa e lifee cycle
cyc e (a.k.a.
(a. .a. software
so twa e process)
p ocess)
Phased approach to software development
Software life cycle (a.k.a. process) models
Waterfall – limitations of Waterfall Model
Incremental - evolutionary prototyping
Exploratory - throwaway prototyping
Spiral model – risk driven process model
Waterfall Model
Requirements
Analysis &
Specification
Architectural
Design
Detailed
Design
Coding
U it
Unit
Testing
Integration
Testing
System &
Acceptance
Testing
Detailed Design
Internal design of individual components
Design of logic and data structures
Coding
Map component design to code
Unit Testing
Test individual components
Integration Testing
Gradually combine components and test combinations
System Testing
Test of entire system against software requirements
Acceptance Test
Test of entire system by user prior to acceptance
Problem
Software requirements are tested late in life cycle
Solution
Use throw-away prototyping
Help ensure requirements are understood
Also first attempt at designing system
Design of key file and data structures
Design of user interface
Early design tradeoffs
Requirements
Analysis &
Specification
Architectural
Design
Detailed
Design
Throwaway
Prototype Coding
U it
Unit
Testing
Integration
Testing
System
Testing
Objectives
T design
Test d i early
l
Experiment with alternative design decisions
Examples of prototyping in design
Algorithm design
Experiment with - speed, accuracy
Early performance analysis
Measure timing parameters
User interface
Requirements
Analysis &
Specification
Architectural
Design
Detailed
Design
Coding
U it
Unit
Throwaway Testing
Prototype
Integration
Testing
System
Testing
Problem
O
Operational
ti l system
t available
il bl late
l t in
i life
lif cycle
l
Solution
Use incremental development
Also known as evolutionary prototyping
Objective
Subset of system working early
Gradually build on
Prototype evolves into production system
Requirements
Analysis &
p
Specification
Architectural
Design
Incremental
Component
Construction
Incremental
y
System
Integration
System &
Evolutionary Acceptance
Prototype Testing
Tradeoff
Rapid development
Quality of product
Throw-away prototype
Speed, not quality is goal
Must not evolve into production system
Evolutionary prototype
Must emphasize quality
Maintainability is key issue
Requirements
Analysis &
p
Specification
Architectural
Design
Incremental
Component
Throwaway Construction
Prototype
Incremental
y
System
Integration
System &
Evolutionary Acceptance
Prototype Testing
1. Define objectives,
alternatives, and constraints 2. Analyze risks
• Phase
– Time between two major milestones
• Phases in Unified Process
– Inception
• Seed idea is developed
– Elaboration.
• Software architecture is defined
– Construction.
• Software is built to the point at which it is ready for release
– Transition.
• Software is turned over to the user community.
Phases
Requirements
Analysis
Design
Implementation
Test
Iterations
Copyright © 2011 Hassan Gomaa 29
Class Class
Class
attributes attributes
operations
anotherObject
anObject :Class
:Class
Objects
Customer Account
Objects
anotherCustomer
aCustomer:Customer
:Customer
anAccount :Account
Attributes
• Attribute
– Data value held by object in class
• Example of Attributes
– E.g., account number, balance
• Each object instance has specific value of attribute
– John’s account number is 1234
a y s account
– Mary’s accou t number
u be iss 5678
• Attribute name is unique within class
• Figure 3.2 Example of class with attributes
Account
accountNumber : Integer
balance : Real
Account
accountNumber : Integer
balance : Real
readBalance () : Real
credit (amount : Real)
debit (amount : Real)
open (accountNumber : Integer)
close ()
Information Hiding
• Example of Stack
• Conventional approach
– Stack data structure is global
– Stack accessed by modules
– Module corresponds to procedure / function / subroutine
– Problem
– C
Change
a ge to stack
stac data st
structure
uctu e has
as global
g oba impact
pact
• Consider
– Array implementation (Fig. 3.4) changed to
– Linked list implementation (Fig. 3.6)
• Every module is impacted by change
Copyright © 2011 Hassan Gomaa 39
Stack Implemented
As Array
Module Module
A B
PUSH POP
N MAX SIZE = N
X INDEX
Stack Array
Stack Implemented
As Linked List
Top
Bottom
• Example of Stack
• Information hiding solution
– Hide stack data structure and internal linkage
– Specify operations on stack data structure
– Access to stack only via operations
• Consider
– Array implementation (Fig. 3.5) changed to
– Linked list implementation (Fig. 3.7)
• Change to stack only impacts Stack object
MAX SIZE
Stack INDEX
X
Information
Hiding
Object
Stack Array
Stack
Figure 3.7 Example of Information Hiding
Information
Hiding
Object
# Entries Top
«entity»
Account
accountNumber: Integer
balance: Real
«entity» «entity»
CheckingAccount SavingsAccount
Sequential problems
Activities happen in strict sequence
E.g., compiler, payroll
Sequential solution = program
Concurrent problems
Many activities happen in parallel
E g multi-user
E.g., multi user interactive system,
system air traffic
control system
Sequential solution to concurrent problem increases
design complexity
• Concurrent System
– Consists of many activities (tasks) that execute in
parallel
• Real-Time system
– Concurrent system with timing deadlines
• Distributed application
– Concurrent system executing on geographically
distributed nodes
• Characteristics
C c e s cs ofo concurrent
co cu e task s
– A.k.a. (lightweight) process, thread
• Active object, concurrent object
– One sequential thread of execution
– Represents execution of
• Sequential program
• Sequential part of concurrent program
– Concurrent system
• Many tasks execute in parallel
• Tasks need to interact with each other
Message Queue
Send Message Wait for Message
Brake Pressed
Initial Braking Initial Not Braking
Brake Released
Accel
Accelerating
Design Strategies
Transform Analysis
• Structured Analysis
- Data flow diagram
Design concepts
Finite state machine, concurrent task, information hiding
Design structuring criteria
Object, subsystem and task structuring criteria
Design strategy
Develop analysis model, then map to design model
Design
g notation
UML (Unified Modeling Language)
Factory Operator
ClassPart1 ClassPart2
V1:
Operator
Request «user interface»
:Operator
Interface
V1.3:
Displayed Info
:FactoryOperator
V1.1: Workstation V1.2:
Status Workstation
Request Data
«entity»
:Workstation
Status
Server
Copyright © 2011 Hassan Gomaa 58
Review
• Follows general guidelines of Software Engineering Body
of Knowledge (SWEBOK) – Chapter 3 Software Design
• Published byy IEEE – 2004 Version
– Fundamentals of Software Design
– Software Design Process
– Software Design Concepts
– Software Design Notations and Methods