Design Overview Design Overview (Ch 6) (Global) System Design (Ch 7) 

advertisement
Design Overview

Design Overview (Ch 6)





(Global) System Design (Ch 7)





Review of RAD
System Design
System Design Concepts
System Design Goals
Design Goals
Software Architecture
Boundary Use Cases
SDD
Subsystem Design
 Patterns (Ch 8)
 Interfaces (Ch 9)
 Mapping to Code (Ch 10)
COP 3331
Object-Oriented Analysis and Design
1
Re-Use

Design Patterns
 Adapter, Bridge
 Strategy, Command, Composite
 Abstract Factory

Frameworks





Infrastructure
Middleware
Application
Whitebox / Blackbox
Libraries
 Domain neutral
 Independent and fine grain
 Control passive

Components
 Predefined instances (pre-compiled code)
 Not modifiable
COP 3331
Object-Oriented Analysis and Design
2
Inheritance

Specification inheritance (recommended)





Interface inheritance
Re-use interface
Create a subtype
Example (from 3330): vehicle / truck / tanker
Implementation inheritance (use with caution)
 Re-use (implementation) code
 Example: List / OrderedList
 Problems:
 Not extensible (hard to change the implementation)
 Not a subtype: can’t substitute for base class
 C++ private inheritance overcomes subtype issue

Liskov Substitution Principle (LSP)
 Definition: S is a subtype of T iff an object of type S can be substituted whenever an
object of type T is expected
 Principle: Use inheritance only for subtyping
COP 3331
Object-Oriented Analysis and Design
3
Delegation




Preferred for code reuse
Extensible: facilitates change of implementation
Does not create a false supertype
Delegation and Inheritance work together in design patterns
COP 3331
Object-Oriented Analysis and Design
4
Design Patterns

Name
 Uniquely identifies pattern
 Evokes details to designer

Problem description
 Describes situations appropriate for using the pattern
 Usually includes modifiability, extensibility, and nonfunctional design goals

Solution
 State as a set of collaborating entities (mostly classes and objects)
 Typically includes an illustration

Consequences
 Describe the trade-offs and alternatives with respect to the design goals being
addressed
COP 3331
Object-Oriented Analysis and Design
5
Adaptor [A.2]
Client
ClientInterface
LegacyClass
Request()
ExistingRequest()
adaptee
Adapter
Request()
COP 3331
Object-Oriented Analysis and Design
6
Adaptor Example




C++: std::stack (or fsu::CStack)
Uses vector (existing code) to define stack interface
http://www.cs.fsu.edu/~lacher/courses/COP4530/lectures/adts/sl
ide19.html
Note: “inheritance” is conceptual, but not necessarily realized
by inheritance in the specific language!
COP 3331
Object-Oriented Analysis and Design
7
Bridge [A.3]
(wikipedia)
COP 3331
Object-Oriented Analysis and Design
8
Bridge Example
(text fig. 8-7)
Arena
LeagueStore
Stub Store
Implementor
COP 3331
imp
LeagueStoreImplementor
JDBC Store
Implementor
XML Store
Implementor
Object-Oriented Analysis and Design
9
Comparing Adaptor and Bridge

Using Inheritance and Delegation
 Adaptor: inherits interface then delegates implementation
 Bridge: delegates abstract implementation then derives specific implementations
 Can derive from either construct

Adaptor
 Assumes existing (“legacy”) code
 Adapted code may be old and ugly or modern and useful
 Either way, you are not intending to change the existing code

Bridge
 Assumes you have not yet implemented the interface
 Facilitates different implementation choices
COP 3331
Object-Oriented Analysis and Design
10
Strategy [A.9]
(Text fig 8-10)
Application (client)
NetworkConnection (context)
open()
close()
send()
receive()
send()
receive()
setNetworkInterface()
LocationManager (policy)
Ethernet
open()
close()
send()
receive()
COP 3331
NetworkInterface (strate
WaveLAN
open()
close()
send()
receive()
Object-Oriented Analysis and Design
UMTS
open()
close()
send()
receive()
11
Strategy Example




The Strategy class (NetworkInterface) provides common
interface to various concrete networks
The Context class (NetworkConnection) gives client access to
connection methods
Client is a mobile application
Policy monitors current location and (re)configures network
connections with appropriate network interfaces
COP 3331
Object-Oriented Analysis and Design
12
Command [A.4]
(text fig. 8-13)
Match
*
play()
replay()
Move
execute()
«binds»
TicTacToeMove
GameBoard
execute()
ChessMove
execute()
COP 3331
Object-Oriented Analysis and Design
13
Composite [A.5]
*
Component
move()
resize()
Label
Button
Checkbox
Composite
move()
resize()
Window
Panel
Applet
COP 3331
Object-Oriented Analysis and Design
14
Figure 8-14, Anatomy of a preference dialog. Aggregates, called
Panels, are used for grouping user interface objects that need to
be resized and moved together.
Top panel
Main panel
Button panel
COP 3331
Object-Oriented Analysis and Design
15
Figure 8-15, UML object diagram for the user interface objects of
Figure 8-14.
prefs:Window
top:Panel
main:Panel
title:Label
c1:Checkbox
buttons:Panel
ok:Button
c2:Checkbox
cancel:Button
c3:Checkbox
c4:Checkbox
COP 3331
Object-Oriented Analysis and Design
16
Abstract Factory [A.1]
TheftApplication
HouseFactory
createBulb()
createBlind()
EIBFactory
LuxmateFactory
createBulb()
createBlind()
createBulb()
createBlind()
LightBulb
EIBBulb
COP 3331
Blind
LuxmateBulb
Object-Oriented Analysis and Design
EIBBulb
LuxmateBulb
17
Façade [A.6]
Encapsulate complex systems
COP 3331
Object-Oriented Analysis and Design
18
Observer [A.7]
(fig 8-22)
observers
Subject
1
subscribe(Subscriber)
unsubscribe(Subscriber)
notify()
Observer
update()
GameBoard
state
getState()
playMove()
COP 3331
*
Object-Oriented Analysis and Design
MatchView
gameBoard
update()
19
Proxy [A.8]

Whenever direct access is undesirable (security, performance,
flexibility)
COP 3331
Object-Oriented Analysis and Design
20
Download