Transcript PowerPoint

CS 501: Software Engineering
Lecture 15
System Architecture and Design 2
1
CS 501 Spring 2004
Administration
2
CS 501 Spring 2004
Quiz 2, Question 1
You are developing the requirements for an online shopping
system. To place an order, a user connects to the system, searches
to find items to purchase, selects one or more items, and supplies
credit card information to pay for them.
(i)
Create a scenario for a user making a purchase.
A scenario should follow an individual user through a single
interaction with the system.
See Lecture 8, slides 11 to 14 for a typical example.
3
CS 501 Spring 2004
Quiz 2, Question 1
(ii) Develop a use case diagram and brief specification
for a use case, PlaceOrder, which is modeled on this
scenario. The use case should show a relationship to
a previously specified use case, Pay, which models
credit card payments. (You do not need to specify
the Pay use case.)
<<includes>>
PlaceOrder
Pay
Shopper
The subject of a use case is an actor, with a generic role.
4
For an example of a specification, see Lecture 8 slides
26-27
CS 501 Spring 2004
Quiz 2, Question 1
(iii) A user might interact with the online shopping system
in other ways. Draw a diagram for a different use case in
which the same actor interacts with the online shopping
system.
CheckOrder
Shopper
Note same actor for this different use case.
5
CS 501 Spring 2004
Coupling and Cohesion
Coupling is a measure of the dependencies between two
subsystems. If two systems are strongly coupled, it is hard to
modify one without modifying the other.
Cohesion is a measure of dependencies within a subsystem.
If a subsystem contains many closely related functions its
cohesion is high.
An ideal breakdown of a complex system into subsystems has
low coupling between subsystems with high cohesion within
subsystems.
6
CS 501 Spring 2004
Architectural Styles
An architectural style is system architecture that recurs in
many different applications.
See: Mary Shaw and David Garlan, Software architecture:
perspectives on an emerging discipline. Prentice Hall,
1996
7
CS 501 Spring 2004
Architectural Style: Repository
Example: A digital library
Input
components
Transactions
Repository
Advantages: Flexible architecture for data-intensive systems.
Disadvantages: Difficult to modify repository since all other
components are coupled to it.
8
CS 501 Spring 2004
Architectural Style: Repository with
Storage Access Layer
Repository
Input
components
This is sometimes
called a "glue" layer
Storage
Access
Transactions
Data Store
Advantages: Data Store subsystem can be changed without
modifying any component except the Storage Access.
9
CS 501 Spring 2004
Architectural Style:
Model/Controller/View
Example: An unmanned aircraft
Controller
Model
View
Controller: Sends control signals to the aircraft and receives
instrument readings.
Model: Translates data received from and sent to the aircraft
into a model of flight performance. It uses domain knowledge
about the aircraft and flight.
View: Displays information about the aircraft to the user.
10
CS 501 Spring 2004
Architectural Style: Client/Server
Example: the Web
Mozilla
client
Apache
server
The control flows in the client and the server are independent.
communication between client and server follows a protocol.
In a peer-to-peer architecture, the same component acts as
both a client and a server.
11
CS 501 Spring 2004
Architectural Style: Pipe
Example: A three-pass compiler
Lexical
analysis
Code
generation
Parser
Output from one subsystem is the input to the next.
12
CS 501 Spring 2004
Distributed Computing:
General Problem
An application that is running on one computer wishes to
use data or services provided by another:
• Network connection
private, public, or virtual private network
location of firewalls
• Protocols
point-to-point, multicast, broadcast
message passing, RPC, distributed objects
stateful or stateless
• Performance
quality of service
13
CS 501 Spring 2004
Network Choices
Public Internet:
Ubiquitous -- worldwide
Low cost
Private network:
Security / reliability
Predictable performance
Choice of protocols (not constrained to TCP/IP)
14
CS 501 Spring 2004
Quality of Network Services
Criteria in choosing a system architecture
Performance
Maximum throughput
Latency
Variations in throughput
Real-time media (e.g., audio)
Business
Suppliers, cost
Trouble shooting and maintenance
15
CS 501 Spring 2004
Firewall
Public
network
Private
network
Firewall
A firewall is a computer at the junction of two network
segments that:
•
Inspects every packet that attempts to cross the boundary
•
Rejects any packet that does not satisfy certain criteria, e.g.,
an incoming request to open a TCP connection
an unknown packet type
16
Firewalls provide security at a loss of flexibility and a cost of
system administration.
CS 501 Spring 2004
Distributed Data
two copies of the
same data
17
CS 501 Spring 2004
Distributed Data and Replication
Distributed Data
Data is held on several computer systems. A transaction may need
to assemble data from several sources.
Replication
Several copies of the data are held in different locations.
Mirror: Complete data set is replicated
Cache: Dynamic set of data is replicated (e.g., most recently used)
With replicated data, the biggest problems are concurrency and
consistency.
18
CS 501 Spring 2004
Distributed Computing:
Searching
Broadcast Searching
User
User interface
server
Databases
This is an example of a multicast protocol.
The primary difficulty is to avoid troubles at
one site degrading the entire system (e.g.,
every transaction cannot wait for a system to
time out).
19
CS 501 Spring 2004
Distributed Computing:
Stateless Protocol v. Stateful
Stateless protocol
Example: http
Open connection
Send message
Return reply
Close connection
State in http must be sent with every message
(e.g., as parameter string)
Cookies are a primitive way of retaining
some state
20
CS 501 Spring 2004
Stateless Protocol v. Stateful
Stateful (session) protocol
Example: Z39.50
Open connection
Begin session
Interactive session
End session
Close connection
Client and server remember the results of previous
transactions (e.g., authentication, partial results) until
session is closed.
21
CS 501 Spring 2004
Distributed Computing:
UseNet
This is an example of an epidemic
protocol. Such protocols are
especially useful in networks with
intermittent connectivity, e.g.,
mobile computing.
The biggest problem is ensuring that
the data is distributed effectively.
22
CS 501 Spring 2004
Distributed Computing:
The Domain Name System
First attempt to resolve
www.cs.cornell.edu
.edu
server
1
2
3
23
cornell.edu
server
cs.cornell.edu
server
CS 501 Spring 2004
Distributed Computing:
The Domain Name System
Better method
local DNS
server
1
almaden.ibm.com
cornell.edu
Local ece.cmu.edu
cache ibm.com
acm.org
.edu
24
.edu
server
2
cornell.edu
server
3
cs.cornell.edu
server
CS 501 Spring 2004
Distributed Computing
Domain Name System
For details of the actual protocol read:
Paul Mockapetris, "Domain Names - Implementation and
Specification". IETF Network Working Group, Request for
Comments: 1035, November 1987.
http://www.ietf.org/rfc/rfc1035.txt?number=1035
25
CS 501 Spring 2004
Distributed Computing:
Web Server
http message
daemon
TCP port 80
spawned processes
The daemon listens at port 80
When a message arrives it:
spawns a processes to handle the message
returns to listening at port 80
26
CS 501 Spring 2004
Time-Critical Systems
A real time (time-critical) system is a software system
whose correct functioning depends upon the results
produced and the time at which they are produced.
• A soft real time system is degraded if the results
are not produced within required time constraints
• A hard real time system fails if the results are
not produced within required time constraints
27
CS 501 Spring 2004
Time-Critical System:
Autonomous Land Vehicle
GPS
Steer
Sonar
Model
Laser
Control
signals
Throttle
Controls
Sensors
28
Signal
processing
CS 501 Spring 2004
Time-Critical System:
CD Controller
4
Input
block
7
3
2
5
6
Circular buffer
29
1
Output
block
CS 501 Spring 2004
Software Considerations of System
Architectures
In some types of system architecture, non-functional
requirements of the system may dictate the software
design and development process.
30
CS 501 Spring 2004
Time-Critical System:
Routers and Other Network Computing
•
Interoperation with third party devices
•
Support for several versions of protocols
•
Restart after total failure
•
Defensive programming -- must survive
=> erroneous or malicious messages
=> extreme loads
Time outs, dropped packets, etc.
Evolution of network systems
•
•
31
CS 501 Spring 2004
Time-Critical System:
Software Development
Developers of advanced time-critical software spend
almost all their effort developing the software
environment:
•
Monitoring and testing -- debuggers
•
Crash restart -- component and system-wide
•
Downloading and updating
• Hardware troubleshooting and reconfiguration
etc., etc., etc.
32
CS 501 Spring 2004
Software Considerations of System
Architectures: Performance
Resource considerations may dictate software design and
implementation:
• Low level language (e.g., C) where programmer has close
link to machine
• Inter-process communication may be too slow (e.g., C
fork).
• May implement special buffering, etc., to control timings
33
CS 501 Spring 2004
Software Considerations of System
Architectures: Multi-Threading
Several similar threads operating concurrently:
•
•
Re-entrant code -- separation of pure code from
data for each thread
May be real-time (e.g., telephone switch) or non-time
critical
The difficult of testing real-time, multi-threaded systems
may determine the entire software architecture.
•
34
Division into components, each with its own
acceptance test.
CS 501 Spring 2004
Time-Critical System:
Embedded Real-time Systems
Software and hardware are combined to provide an
integrated unit, usually dedicated to a specific task:
•
•
•
•
•
Digital telephone
Automobile engine control
GPS
Scientific instruments
Seat bag controller
The software may be embedded in the device in a manner
that cannot be altered after manufacture.
35
CS 501 Spring 2004
Software Considerations:
Embedded Real-time Systems
Hardware v. Software
Design of embedded systems requires close understanding
of hardware characteristics
•
Special purpose hardware requires special tools and
expertise.
•
Some functions may be implemented in either
hardware of software (e.g., floating point unit)
•
Design requires separation of functions
Distinction between hardware and software may be
blurred.
36
CS 501 Spring 2004
Software Considerations of System
Architectures: Continuous Operation
Many systems must operate continuously
•
Software update while operating
•
Hardware monitoring and repair
•
Alternative power supplies, networks, etc.
•
Remote operation
These functions must be designed into the fundamental
architecture.
37
CS 501 Spring 2004