Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
OO Design Overview
Architectural Design
Use Case Design
Subsystem Design
Class Design
OO Design Overview
Understanding Design
A process that uses the products of
analysis to produce a specification for
implementing a system.
A logical description of how a system will
work.
Emphasizes a conceptual solution (in
software and hardware) that fulfills the
requirements, rather than its
implementation.
do the right thing (analysis), and do the
thing right (design).
Object Oriented Analysis and Design
Design
Focus on understanding
the problem
Idealized design
Behavior
System structure
Functional requirements
A small model
Focus on understanding
the solution
Operations and
Attributes
Performance
Close to real code
Object lifecycles
Non-functional
requirements
A large model
Architectural Design
General
functionality
10
11
12
13
<<layer>>
Package Name
14
<<layer>>
Business-Specific
<<layer>>
Middleware
15
16
17
18
19
20
21
22
23
24
25
26
Client A
...
Client N
Server
27
Client A
Application
Business Object
Services
Client B
Application
WWW Browser
DCOM
CORBA Beans
ADO/R
Business Object
Engine
Business
Object
Server
COM
MTS
Beans
ETS
Business Object
Services
Business Object
Engine
Relational Database
Server(s)
Client C
28
Web
Serve
r
HTML
CGI
ASP
Java
Business Object
Services
Business Object
Engine
Client/Browser
Web Server
Application Server
Database
Server
Object Oriented Analysis and Design
Legend
System
Native languages
29
30
Model-View-Controller Architecture
The model-view-controller architecture (MVC) separates application data
(contained in the model) from graphical presentation components (the view) and
input-processing logic (the controller).
31
32
5) Solution
A number of Knowledge Agents have access to a shared data store
called the Blackboard. The blackboard provides an interface to
inspect and update its content. The Control module/object activates
the agents following some strategy. Upon activation an agent inspects
that blackboard to see if it can contribute to solving the problem. If
the agent determines that it can contribute, the control object can
allow the agents to put its partial (or final) solution on the board.
Object Oriented Analysis and Design
33
34
35
36
Design Model
Use case
<<layer>>
Special Application
<<layer>>
General Application
Glossary
<<layer>>
General Services
<<layer>>
System Services
Architecture Mechanism
Supplementary
Specification
Object Oriented Analysis and Design
37
Technical Memo
All architectural methods recommend keeping a
record of alternative solutions, decisions, influential
factors, and motivations for the noteworthy issues and
decisions.
Such records have been called technical memos,
issue cards, and architectural approach documents,
with varying degrees of formality and sophistication.
In some methods, these memos are the basis for yet
another step of review and refinement.
38
39
40
Architectural Representation
(Brief summary of the most architecturally significant use cases. UML interaction diagrams for
some architectural significant use-case realizations, or scenarios, with commentary on the
diagrams explaining how they illustrate the major architectural elements.)
Deployment View
(UML class and interaction diagrams illustrating the processes and threads of the system. Group
this by threads and processes that interact. Comment on how the interprocess communication
works (e.g., by Java RMI).
Use-Case View
(UML package diagrams, and class diagrams of major elements. Commentary on the large scale
structure and functionality of major components.)
Process View
(Reference to the Supplementary Specification to view the Factor Table. Also, the set of technical
memos the summarize the decisions.)
Logical View
(Summary of how the architecture will be described in this document, such as using by technical
memos and the architectural views. This is useful for someone unfamiliar with the idea of
technical memos or views. Note that not all views are necessary.)
(UML deployment diagrams showing the nodes and allocation of processes and components.
Commentary on the networking.)
Data View
Overview of the persistent data schema, the schema mapping from objects to persistent data
(usually in a relational database), the mechanism of mapping from objects to a database,
database stored procedures and triggers.
A view onto the UP Data Model, visualized with UML class diagrams used to describe a data
model.
41
42
43
44
45
Packages
Provide behavior
Completely
encapsulate their
contents
Are easily replaced
Dont provide
behavior
Dont completely
encapsulate their
contents
May not be easily
replaced
Client Class
<<subsystem>>
Subsystem A
Package B
ClassB1
ClassB2
Subsystem example
47
Identifying Subsystems
Superman Class
ClassA
Y()
Z()
<<Interface>>
<<subsystem>>
Subsystem K
Y()
Z()
48
Design
<<subsystem>>
Billing System
<<boundary>>
BillingSystem
IBillingSystem
//submit bill()
<<boundary>>
CourseCatalogSystem
<<subsystem>>
Course Catalog
System
ICourseCatalogSystem
getCourseOfferings(forSemester : Semester, forStudent : Student) : CourseOfferingList
initialize()
49
ICourseCatalogSystem
getCourseOfferings(forSemester : Semester, forStudent : Student) : CourseOfferingList
initialize()
50
getCourseOfferings()
initialize()
Faade in subsystem
For subsystems, the most common pattern of access is
Facade, a GoF design pattern.
a public facade object defines the services for the subsystem,
and clients collaborate with the facade, not internal
subsystemcomponents
51
52
53
54
Client Package
Supplier
Package
Dependency Implications
Changes to the Supplier package may affect the Client package
The Client package cannot be reused independently because it
depends on the Supplier package
55
B
A
Hierarchy
should be
acyclic
C
B
A'
C
56
57
58
PackageB
Public visibility
+ Class B1
- Class B2
Private visibility
OO Principle: Encapsulation
Object Oriented Analysis and Design
59
Upper
Layer
Lower
Layer
X
B
X = Coupling violation
Object Oriented Analysis and Design
60
61
62
63
64
No Cycles in Packages
65
Subsystem Design
66
67
Use-Case Realization
Subsystem
Design
Design
Guidelines
Object Oriented Analysis and Design
Use-Case Realization
(updated)
Design Classes
68
69
<<subsystem>>
Subsystem Name
Realization (Canonical form)
Interface
<<subsystem>>
Subsystem Name
Interface
70
Subsystem
Subsystem Guidelines
Goals
Loose coupling
Portability, plug-and-play compatibility
Insulation from change
Independent evolution
Strong Suggestions
Dont expose details, only interfaces
Only depend on other interfaces
<<subsystem>>
A
<<subsystem>>
B
<<subsystem>>
C
71
ICourseCatalogSystem
<<subsystem>>
CourseCatalogSystem
<<subsystem>> package
<<subsystem proxy>> class
Interfaces start with an I
<<subsystem>>
CourseCatalogSystem
<<subsystem proxy>>
CourseCatalogSystem
ICourseCatalogSystem
Object Oriented Analysis and Design
72
73
Subsystem Responsibilities
Subsystem responsibilities defined by
interface operations
Model interface realizations
<<subsystem>>
CourseCatalogSystem
getCourseOfferings()
subsystem responsibility
Object Oriented Analysis and Design
74
75
<<subsystem>>
Server Support
Flexible,
Preferred
Server
Supporting
Types
76
77
78
Supplementary
Specifications
Use-Case Realization
Use-Case
Design
Design Classes
use-case
Object Oriented Analysis and Design
79
Use-Case Realization
(Refined)
80
81
Class Design
82
83
84
85
SubWindow
Button
DropDownList
MainForm
86
Design
FatClass
- transientBookeeping
+ getCommonlyUsedAtt1()
+ getCommonlyUsedAtt2()
+ getRarelyUsedAtt3()
+ getRarelyUsedAtt4()
1
FatClassDataHelper
- commonlyUsedAtt1
- commonlyUsedAtt2
Object Oriented Analysis and Design
87
1
FatClassLazyDataHelper
- rarelyUsedAtt3
- rarelyUsedAtt4
88
:ClassA
:ClassB
:ClassA
// Perform responsibility
Manager functions
Need for class copies
Need to test for equality
:ClassB
performResponsibility():result
89
90
91
Operation Visibility
Visibility is used to enforce encapsulation
May be public, protected, or private
Private operations
Protected
operations
Public
operations
92
+ Public access
# Protected access
- Private access
Class
- privateAttribute
# protectedAttribute
+publicOp()
# protectedOp()
- privateOp()
93
Scope
Determines number of instances of the
attribute/operation
Instance: one instance for each class instance
Classifier: one instance for all class instances
94
Example: Scope
<<entity>>
Student
- name
- address
- studentID
- nextAvailID : int
+ addSchedule(theSchedule : Schedule, forSemester : Semester)
+ getSchedule(forSemester : Semester) : Schedule
+ hasPrerequisites(forCourseOffering : CourseOffering) : boolean
# passed(theCourseOffering : CourseOffering) : boolean
+ getNextAvailID() : int
95
(from Registration)
+ submitSchedule()
+ saveSchedule()
+ getCourseOfferings() : CourseOfferingList
+ getCurrentSchedule(forStudent : Student, forSemester : Semester) : Schedule
+ deleteCurrentSchedule()
<<class>> + new(forStudent : string)
+ getStudent(withID : string) : Student
<<Interface>>
ICourseCatalogSystem
+ getCourseOfferings()
+ initialize()
+currentSchedule
0..1
0..1
0..1
<<entity>>
Schedule
(from University Artifacts)
0..*
0..*
0..*
+registrant
0..1
<<entity>>
Student.
+alternateCourses
+primaryCourses
+ getTuition() : double
+ addSchedule(theSchedule : Schedule)
+ getSchedule(forSemester : Semester) : Schedule
+ deleteSchedule(forSemester : Semester)
+ hasPrerequisites(forCourseOffering : CourseOffering) : boolean
# passed(theCourseOffering : CourseOffering) : boolean
<<class>> + getNextAvailID() : int
+ getStudentID() : int
+ getName() : string
+ getAddress() : string
Object Oriented Analysis and Design
96
0..2
0..4
<<entity>>
CourseOffering
(from University Artifacts)
Define Methods
What is a method?
Describes operation implementation
Purpose
Define special aspects of operation
implementation
Things to consider :
Special algorithms
Other objects and operations to be used
How attributes and parameters are to be
implemented and used
How relationships are to be implemented and used
97
Define States
Purpose
Design how an objects state affects its behavior
Develop statecharts to model this behavior
Things to consider :
Which objects have significant state?
How to determine an objects possible states?
How do statecharts map to the rest of the
model?
98
What is a Statechart?
A directed graph of states (nodes) connected
by transitions(directed arcs)
Describes the life history of a reactive object
State
Event
State Name
event(args)
[guard condition]
/ operation(args)
^target.sendEvent(args)
Action
Activity
Object Oriented Analysis and Design
Transition
99
Special States
Initial state
The state entered when an object is created
Mandatory
Can only have one initial state
Initial state
Final state
Indicates the objects end of life
Optional
May have more than one
100
Final state
numStudents > = 10
Open
Closed
0..1
0..*
Link to Professor
Exists
Assigned
CourseOffering
Object Oriented Analysis and Design
101
Link to Professor
Doesnt Exist
Unassigned
<<entity>>
CourseOffering
+ addProfessor()
+ removeProfessor()
0..*
0..1
+instructor
<<entity>>
Professor
102
<<entity>>
CourseOffering
+ addProfessor()
+ removeProfessor()
0..*
0..1
+instructor
<<entity>>
Professor
Unassigned
addProfessor
removeProfessor
Assigned
Object Oriented Analysis and Design
103
Actions
activity
State B
do: activity
action
State C
entry: action
104
Example: Statechart
add student / numStudents = numStudents + 1
/ numStudents = 0
addProfessor
cancel
Cancelled
do: Send cancellation notices
close
removeProfessor
[ numStudents = 10 ]
cancel
cancel
Full
add student /
numStudents = numStudents + 1
[ numStudents = 10 ]
Assigned
close
Committed
do: Generate class roster
105
Open
Unassigned
Closed
closeRegistration
Cancelled
do: Send cancellation notices
close
cancel
cancel
substate
Full
remove a professor
add a professor
[ numStudents = 10 ]
close
Assigned
add student /
numStudents = numStudents + 1
H
106
Committed
do: Generate class roster
107
Open
[numStudents = 10]
Full
CourseOffering
add student /
numStudents = numStudents + 1
/- numStudents
+ addStudent()
(Stay tuned for derived attributes)
108
109
Attribute Representations
Specify name, type, and optional default value
attributeName : Type = Default
Follow naming conventions of implementation
language and project
Type should be an elementary data type in
implementation language
Built-in data type, user-defined data type, or
user-defined class
Specify visibility
Public: +
Private: -
Protected: #
Object Oriented Analysis and Design
110
Derived Attributes
What is a derived attribute?
An attribute whose value may be calculated
based on the value of other attribute(s)
111
<<control>>
RegistrationController
(from Registration)
0..1
+currentSchedule
0..1
0..1
<<entity>>
Schedule
(from University Artifacts)
- semester : Semester
0..*
0..*
+registrant
0..*
+alternateCourses
+primaryCourses
0..1
<<entity>>
Student.
(from University Artifacts)
0..2
<<entity>>
CourseOffering
- name : string
- address : string
<<class>> - nextAvailID : int
- studentID : int
- dateofBirth : Date
Object Oriented Analysis and Design
0..4
Define Dependency
What Is a Dependency?
A relationship between two objects
Client
Supplier
Purpose
Determine where structural relationships are NOT
required
113
Dependency
Client
Supplier1
Supplier2
114
115
116
courseCatalog
<<control>>
RegistrationController
(from Registration)
currentSchedule
+ // submit schedule()
+ // save schedule()
+ // create schedule with offerings()
+ // getCourseOfferings(forSemester) : CourseOfferingList
0..1
0..1
1
registrant
0..4
<<entity>>
CourseOffering
(from University Artifacts)
- number : String = "100"
- startTime : Time
- endTime : Time
- days : Enum
<<entity>>
Student
(from University Artifacts)
0..1 + submit()
+ // save()
# any conflicts?()
+ // create with offerings()
0..*
0..*
0..*
alternateCourses
primaryCourses
0..2
0..1
- name
- address
- StudentID : int
<<entity>>
Schedule
(from University Artifacts)
- semester
+ addStudent(studentSchedule : Schedule)
+ removeStudent(studentSchedule : Schedule)
+ new()
+ setData()
117
Global visibility
<<control>>
RegistrationController
(from Registration)
currentSchedule
+ // submit schedule()
+ // save schedule()
+ // create schedule with offerings()
+ // getCourseOfferings(forSemester) : CourseOfferingList
0..1 + submit()
+ // save()
# any conflicts?()
+ // create with offerings()
0..*
0..*
0..*
alternateCourses
primaryCourses
0..1
Field visibility
0..1
Field visibility
registrant
0..2
0..4
<<entity>>
CourseOffering
(from University Artifacts)
- number : String = "100"
- startTime : Time
- endTime : Time
- days : Enum
0..1
- name
- address
- StudentID : int
<<entity>>
Student
(from University Artifacts)
<<entity>>
Schedule
(from University Artifacts)
- semester
+ addStudent(studentSchedule : Schedule)
+ removeStudent(studentSchedule : Schedule)
+ new()
+ setData()
Parameter visibility
118
Define Associations
Purpose
Refine remaining associations
119
What is Composition?
A form of aggregation with strong
ownership and coincident lifetimes
The parts cannot survive the whole/aggregate
Part
Whole
Part
Whole
Composition
120
1..*
0..*
Part
Multiplicity
=1
Non-shared
Aggregation
Whole
0..*
Part
Whole
Multiplicity = 1
1
0..*
Composition
121
Part
Aggregation or Composition?
Consideration
Lifetimes of Class1 and Class2
Class1
aggregation
Class1
Class2
composition
122
Class2
Example: Composition
Student
RegisterForCoursesForm
0..*
Schedule
123
RegistrationController
Attributes Vs Composition
Use composition when
Properties need independent identities
Multiple classes have the same properties
Properties have a complex structure and
properties of their own
Properties have complex behavior of their own
Properties have relationships of their own
124
Attributes
- name
- address
<<classifier scope>> - nextAvailID : int
- StudentID : int
- dateofBirth : Date
<<entity>>
Schedule
+ addSchedule()
+ getSchedule()
+ delete schedule()
+ hasPrerequisites()
# passed()
0..*
- Semester
+ submit()
+ // save()
# any conflicts?()
+ // create with offerings()
+ new()
+ passed()
Composition of
separate class
125
primaryCourses CourseOffering
0..*
0..4
?
primaryCourses CourseOffering
Schedule
0..*
Schedule
primaryCourses CourseOffering
0..*
0..4
126
0..4
Association Class
A class
attached to an
association
Contains
properties of a
relationship
One instance per
link
<<entity>>
ScheduleOfferingInfo
status
// mark as selected()
// mark as cancelled()
// is selected?()
<<entity>>
Schedule
0..*
<<entity>>
CourseOffering
0..*
<<entity>>
PrimaryScheduleOfferingInfob
grade
// is enrolled in?()
// mark as enrolled in()
// mark as committed()
127
alternateCourses
0..2
primaryCourses
0..4
0..*
0..2
primaryCourses CourseOffering
Schedule
0..4
0..*
PrimaryScheduleOfferingInfo
- grade: char = I
Design Decisions
alternateCourses
0..*
Schedule
0..2
primaryCourseOfferingInfo
1
PrimaryScheduleOfferingInfo
128
CourseOffering
0..*
Multiplicity Design
Multiplicity = 1, or Multiplicity = 0..1
May be implemented directly as a simple
value or pointer
No further design is required
Professor
CourseOffering
instructor
0..*
0..1
Multiplicity > 1
Cannot use a simple value or pointer
Further design may be required
Professor
0..1
Object Oriented Analysis and Design
CourseOffering
instructor
0..*
129
Needs a
container
instructor
0..1
CourseOffering
<<entity>>
Professor
0..*
0..1
CourseOfferingList
0..1 + new()
+ add()
1
0..*
<<entity>>
CourseOffering
Note
List
Professor
CourseOffering
instructor
0..*
0..1
+instructor
130
Item
List
131
Implicit binding
Formal
arguments
Parameterized
Class
OR
132
CourseOfferingList
1
0..*
After
Item
List
List <CourseOffering>
OR
<<bind>> <CourseOffering>
CourseOfferingList
CourseOffering
133
CourseOffering
Professor
isTeaching( ) : Boolean
0..1
0..*
134
hasInstructor( ) : Boolean