Visual Modeling and the UML. Object Oriented Analysis and Design.
1 IBM Software Group ® Essentials of Visual Modeling with UML 2.0 Principles of Visual Modeling.
-
Upload
muriel-parker -
Category
Documents
-
view
229 -
download
0
Transcript of 1 IBM Software Group ® Essentials of Visual Modeling with UML 2.0 Principles of Visual Modeling.
1
IBM Software Group
®
Essentials of Visual Modeling with UML 2.0Principles of Visual Modeling
2
Objectives
Describe the importance of visual modeling. Define the four principles of visual
modeling. Explain what the Unified Modeling
Language (UML) represents.
3
Where Are We?
What is modeling? Four principles of visual
modeling The UML
4
What Is a Model?
A model is a simplification of reality.
5
Why Model?
Modeling achieves four aims: Helps you to visualize a system as you want it to be. Permits you to specify the structure or behavior of a
system. Gives you a template that guides you in constructing a
system. Documents the decisions you have made.
You build models of complex systems because you cannot comprehend such a system in its entirety.
You build models to better understand the system you are developing.
6
What is modeling? Four principles of visual
modeling The UML
Where Are We?
7
Four Principles of Modeling
The model you create influences how the problem is attacked.
Every model may be expressed at different levels of precision.
The best models are connected to reality. No single model is sufficient.
8
Design ModelProcess Model
Principle 1: The Choice of Model is Important
The models you create profoundly influence how a problem is attacked and how a solution is shaped. In software, the models you choose
greatly affect your world view. Each world view leads to a different
kind of system.
Deployment Model
9
Principle 2: Levels of Precision May Differ
Every model may be expressed at different levels of precision. The best kinds of models let you choose your
degree of detail, depending on:
• Who is viewing the model. • Why they need to view it.
View for DesignersView for Customers
10
Principle 3: The Best Models Are Connected to Reality
All models simplify reality. A good model reflects potentially fatal
characteristics.
11
Principle 4: No Single Model Is Sufficient
No single model is sufficient. Every non-trivial system is best approached through a small set of nearly independent models. Create models that can be built and studied separately,
but are still interrelated.
Process View Deployment View
Logical View
Use-Case View
Implementation View
End-userFunctionality
ProgrammersSoftware management
Performance, scalability, throughputSystem integrators System topology, delivery,
installation, communication
System engineering
Analysts/DesignersStructure
12
What is modeling? Four principles of visual
modeling The UML
Where Are We?
13
What Is the UML?
The UML is a language for• Visualizing• Specifying• Constructing• Documenting
the artifacts of a software-intensive system.
14
The UML Is a Language for Visualizing
Communicating conceptual models to others is prone to error unless everyone involved speaks the same language.
There are things about a software system you can’t understand unless you build models.
An explicit model facilitates communication.
15
The UML Is a Language for Specifying
The UML builds models that are precise, unambiguous, and complete.
16
The UML Is a Language for Constructing
UML models can be directly connected to a variety of programming languages. Maps to Java, C++, Visual Basic, and so on Tables in a RDBMS or persistent store in an
OODBMS Permits forward engineering Permits reverse engineering
17
The UML Is a Language for Documenting
Use Case Diagram
Actor A
Use Case 1
Use Case 2
Use Case 3
Actor B
Class Diagram
GrpFile
read( )
open( )
create( )
fillFile( )
rep
Repository
name : char * = 0
readDoc( )
readFile( )
(from Persistence)
FileMgr
fetchDoc( )
sortByName( )
DocumentList
add( )
delete( )
Document
name : int
docid : int
numField : int
get( )
open( )
close( )
read( )
sortFileList( )
create( )
fillDocument( )
fList
1
FileList
add( )
delete( )
1
File
read( )
read() fill the
code..
Sequence Diagram
user
mainWnd fileMgr :
FileMgr
repositorydocument :
Document
gFile
1: Doc view request ( )
2: fetchDoc( )
3: create ( )
4: create ( )
5: readDoc ( )
6: fillDocument ( )
7: readFile ( )
8: fillFile ( )
9: sortByName ( )
ƯÁ¤¹®¼ ¿¡ ́ ëÇÑ º¸±â¸¦
»ç¿ëÀÚ°¡ ¿äûÇÑ´Ù.
È ÀÏ°ü̧ ®ÀÚ´Â Àоî¿Â
¹®¼ ÀÇ Á¤º¸¸¦ ÇØ´ç ¹®¼
°´Ã¼¿¡ ¼³Á¤À» ¿äûÇÑ´Ù.
È ̧é °´Ã¼´Â ÀоîµéÀÎ
°´Ã¼µé¿¡ ´ëÇØ ÀÌ̧ §º°·Î
Á¤·ÄÀ» ½ÃÄÑ È ̧é¿¡
º¸¿©ÁØ´Ù.
The UML addresses documentation of system architecture, requirements, tests, project planning, and release management.
The UML addresses documentation of system architecture, requirements, tests, project planning, and release management.
Deployment Diagram
Window95
¹®¼ °ü¸®
Ŭ¶óÀ̾ðÆ®.EXE
Windows
NT
¹®¼ °ü¸® ¿£Áø.EXE
Windows
NT
Windows95
Solaris
ÀÀ¿ë¼ ¹ö.EXE
Alpha
UNIX
IBM
Mainframe
µ¥ÀÌŸº£À̽º¼ ¹ö
Windows95
¹®¼ °ü¸® ¾ÖÇø´
ºÐ»ê È °̄æÀÇ Çϵå¿þ¾î¹× ³×Æ®¿÷À¸·ÎÀÇ Á¤º¸ ½Ã½ºÅÛ ¿¬°á ̧ ðµ¨
- À©µµ¿ì 95 : Ŭ¶óÀ̾ðÆ®
- À©µµ¿ì NT: ÀÀ¿ë¼ ¹ö
- À ´̄нº ̧ Ó½Å: ÀÀ¿ë ¼ ¹ö ¹× µ¥ÀÌŸ ¼ ¹ö, Åë½Å ¼ ¹ö
- IBM ¸ÞÀÎÇÁ·¹ÀÓ: µ¥ÀÌŸ ¼ ¹ö, Åë½Å ¼ ¹ö
18
History of the UML
UMLPartners’ Expertise
UML 1.0(Jan. ‘97)
UML 1.1(Sept. ‘97)
UML 1.5(March, ‘03)
UML 2.0(2004)
Other Methods
Booch ‘91 OMT - 1OOSE
Booch ’93 OMT - 2
Public FeedbackUnified Method 0.8
(OOPSLA ’95)
UML 0.9(June ‘96)
UML 0.91(Oct. ‘96)
and
19
Inputs to the UML
FusionOperation descriptions, message numbering
Before and after conditions
Meyer
HarelState charts
Wirfs-BrockResponsibilities
EmbleySingleton classes, High-level view
OdellClassificationObject lifecycles
Shlaer- Mellor
Gamma, et.alFrameworks, patterns, notes
BoochRumbaugh Jacobson
Selic, Gullekson, WardROOM (Real-Time Object-Oriented Modeling)
20
IBM Software Group
®
Essentials of Visual Modeling with UML 2.0 Class Diagrams
21
Objectives
Describe the static view of the system and show how to capture it in a model.
Demonstrate how to read and interpret a class diagram.
Model an association and aggregation and show how to model it in a class diagram.
Model generalization on a class diagram.
22
Where Are We?
Class diagrams Class relationships
Association Aggregation Generalization
23
What Is a Class Diagram?
Static view of a system
CloseRegistrationForm
+ open()+ close registration()
Student
+ get tuition()+ add schedule()+ get schedule()+ delete schedule()+ has pre-requisites()
Schedule- semester
+ commit()+ select alternate()+ remove offering()+ level()+ cancel()+ get cost()+ delete()+ submit()+ save()+ any conflicts?()+ create with offerings()+ update with new selections()
Professor- name- employeeID : UniqueId- hireDate- status- discipline- maxLoad
+ submitFinalGrade()+ acceptCourseOffering()+ setMaxLoad()+ takeSabbatical()+ teachClass()
CloseRegistrationController
+ is registration open?()+ close registration()
24
Class Diagram Usage
When modeling the static view of a system, class diagrams are typically used in one of three ways, to model: The vocabulary of a system Collaborations A logical database schema
25
Example: Class Diagram
Is there a better way to organize class diagrams?
CloseRegistrationForm
LoginForm
Professor
BillingSystem
CloseRegistrationController
RegisterForCoursesForm
Course
CourseCatalogSystem
Student
RegistrationController
CourseOffering
Schedule
26
A general purpose mechanism for organizing elements into groups.
A model element that can contain other model elements.
A package can be used: To organize the model under development As a unit of configuration management
Review: What Is a Package?
University
Artifacts
27
Example: Registration Package
Registration
CloseRegistrationForm CloseRegistrationController
RegisterForCoursesForm RegistrationController
28
Class diagrams Class relationships
Association Aggregation Generalization
Where Are We?
29
What Is an Association?
The semantic relationship between two or more classifiers that specifies connections among their instances.
A structural relationship specifying that objects of one thing are connected to objects of another thing.
CourseStudent Schedule
30
Example: What Associations Can You Find?
: CourseOffering
: RegistrationController
: Schedule
: Student
: PrimaryScheduleOfferingInfo
8: any conflicts?( )
: RegisterForCoursesForm
2: submit schedule( )
4: submit( )3: save( )
7: still open?( )9: add student(Schedule)
5: is selected?( )10: mark as enrolled in( )
6: has pre-requisites(CourseOffering)
1: submit schedule( )
: Student
31
What Is Multiplicity?
Multiplicity is the number of instances one class relates to ONE instance of another class.
For each association, there are two multiplicity decisions to make, one for each end of the association. For each instance of Professor, many Course Offerings
may be taught. For each instance of Course Offering, there may be
either one or zero Professor as the instructor.
Professor CourseOffering
0..1 0..*0..1 0..*
instructor
32
Multiplicity Indicators
2..4
0..1
1..*
0..*
1
*
2, 4..6
Unspecified
Exactly One
Zero or More
Zero or More
Zero or One (optional value)
One or More
Specified Range
Multiple, Disjoint Ranges
33
Example: Multiplicity
RegisterForCoursesForm
CourseOfferingSchedule0..4
0..*Student
0..*
1
RegistrationController1
1
1
1
0..1
0..1
0..1
34
Class diagrams Class relationships
Association Aggregation Generalization
Where Are We?
35
What Is an Aggregation?
A special form of association that models a whole-part relationship between the aggregate (the whole) and its parts. An aggregation is an “is a part-of” relationship.
Multiplicity is represented like other associations.
PartWhole
0..1
1
36
Example: Aggregation
RegisterForCoursesForm
CourseOfferingSchedule0..4
0..*Student
0..*
1
RegistrationController1
1
1
1
0..1
0..1
0..1
37
Class diagrams Class relationships
Association Aggregation Generalization
Where Are We?
38
Review: What Is Generalization?
A relationship among classes where one class shares the structure and/or behavior of one or more classes.
Defines a hierarchy of abstractions where a subclass inherits from one or more superclasses. Single inheritance Multiple inheritance
Is an “is a kind of” relationship.
39
Example: Single Inheritance
One class inherits from another.
CheckingSavings
Superclass (parent)
Subclasses(children)
Generalization Relationship
Descendents
Ancestor
Account
- balance- name- number
+ withdraw()+ createStatement()
40
Example: Multiple Inheritance
A class can inherit from several other classes.
Use multiple inheritance only when needed and always with caution!
FlyingThing Animal
HorseWolfBirdHelicopterAirplane
Multiple Inheritance
41
IBM Software Group
®
Essentials of Visual Modeling with UML 2.0 Interaction Diagrams
42
Objectives
Describe dynamic behavior and show how to capture it in a model.
Demonstrate how to read and interpret: A sequence diagram A communication diagram
Explain the similarities and differences between communication and sequence diagrams.
43
Objects Need to Collaborate
Objects are useless unless they can collaborate to solve a problem. Each object is responsible for its own behavior
and status. No one object can carry out every responsibility
on its own. How do objects interact with each other?
They interact through messages.
44
Objects Interact with Messages
A message shows how one object asks another object to perform some activity.
: Car buyer:RegistrationController :CourseCatalogSystem
getCourseOfferings(forSemester)
Message
45
What is an Interaction Diagram?
Generic term that applies to several diagrams that emphasize object interactions Sequence Diagram Communication Diagram
Specialized Variants Timing Diagram Interaction Overview Diagram
46
Interaction Diagrams
Sequence Diagram Time oriented view of object
interaction
Communication Diagram Structural view of messaging
objectsCommunication
Diagrams
Sequence Diagrams
47
Interaction Diagrams
Timing Diagram Time constraint view of
messages involved in an interaction
Interaction Overview Diagram High level view of interaction
sets combined into logic sequence
Timing Diagrams
Interaction Overview Diagrams
48
Sequence diagrams Communication diagrams Interaction diagram
comparison
Where Are We?
49
What Is a Sequence Diagram?
A sequence diagram is an interaction diagram that emphasizes the time ordering of messages.
The diagram shows: The objects participating in the interaction. The sequence of messages exchanged.
Sequence Diagram
50
Example: Sequence Diagram
: Student :RegisterForCoursesForm :RegistrationController : Course Catalog:CourseCatalogSystem
1: create schedule( )
5: display course offerings( )
2: get course offerings( )
3: get course offerings(forSemester)
6: display blank schedule( )
4: get course offerings( )
Select Offeringsref
51
Sequence Diagram Contents: Objects
:RegisterForCoursesForm :RegistrationController SWTSU Catalog : CourseCatalogSystem
Anonymous Objects
Lifelines
Named Object
52
:RegisterForCoursesForm :RegistrationController SWTSU Catalog : CourseCatalogSystem
: Student : Course Catalog
Sequence Diagram Contents: Actor
Actor instances
53
Sequence Diagram Contents: Messages
ReflexiveMessages
1: create schedule( )
2: get course offerings( )
3: get course offerings(for Semester)
4: get course offerings( )
:RegisterForCoursesForm :RegistrationController SWTSU Catalog : CourseCatalogSystem
: Student : Course Catalog
6: display blank schedule( )
5: display course offerings( )
Message
54
1: create schedule( )
2: get course offerings( )
3: get course offerings(for Semester)
4: get course offerings( )
6: display blank schedule( )
:RegisterForCoursesForm :RegistrationController SWTSU Catalog : CourseCatalogSystem
: Student : Course Catalog
Sequence Diagram Contents: Execution Occurrence
Execution Occurrence
5: display course offerings( )
55
1: create schedule( )
2: get course offerings( )
3: get course offerings(for Semester)
4: get course offerings( )
6: display blank schedule( )
:RegisterForCoursesForm :RegistrationController SWTSU Catalog : CourseCatalogSystem
: Student : Course Catalog
Sequence Diagram Contents: Event Occurrence
Event Occurrence
5: display course offerings( )
56
1: create schedule( )
2: get course offerings( )
3: get course offerings(for Semester)
4: get course offerings( )
6: display blank schedule( )
:RegisterForCoursesForm :RegistrationController SWTSU Catalog : CourseCatalogSystem
: Student : Course Catalog
Sequence Diagram Contents: Interaction Occurrence
5: display course offerings( )
Select Offeringsref
Interaction Occurrence
57
Sequence diagrams Communication diagrams Interaction diagram
comparison
Where Are We?
58
What Is a Communication Diagram?
A communication diagram emphasizes the organization of the objects that participate in an interaction.
The communication diagram shows: The objects participating in the interaction. Links between the objects. Messages passed between the objects.
Communication Diagrams
59
Example: Communication Diagram
: Student
: RegisterForCoursesForm
: RegistrationController : CourseCatalogSystem
5: display course offerings( )6: display blank schedule( )
: Course Catalog1: create schedule( )
2: get course offerings( )
3: get course offerings(forSemester)
4: get course offerings( )
60
Communication Diagrams Contents: Objects
Objects
: RegisterForCoursesForm
: RegistrationController SWTSU Catalog : CourseCatalogSystem
61
Communication Diagram Contents: Actors
: Student : Course Catalog
: RegisterForCoursesForm
: RegistrationController SWTSU Catalog : CourseCatalogSystem
Actors
62
Communication Diagram Contents: Links and Messages
: Student
: RegisterForCoursesForm
: RegistrationController : CourseCatalogSystem
5: display course offerings( )
6: display blank schedule( )
: Course Catalog1: create schedule( )
2: get course offerings( )
3: get course offerings(forSemester)
4: get course offerings( )
Links
Messages
63
Sequence diagrams Communication diagrams Interaction diagram
comparison
Where Are We?
64
Sequence and Communication Diagram Similarities
Semantically equivalent Can convert one diagram to the other without
losing any information Model the dynamic aspects of a system Model a use-case scenario
65
Sequence and Communication Diagram Differences
Sequence diagrams
Communication diagrams
Show the explicit sequence of messages
Show execution occurrence
Better for visualizing overall flow
Better for real-time specifications and for complex scenarios
Show relationships in addition to interactions
Better for visualizing patterns of communication
Better for visualizing all of the effects on a given object
Easier to use for brainstorming sessions
66
IBM Software Group
®
Essentials of Visual Modeling with UML 2.0 Other UML Diagrams
67
Objectives
Demonstrate how to read and interpret a: State machine diagram Component diagram Deployment diagram
68
Where Are We?
State machine diagrams Component diagrams Deployment diagrams
69
Review: An Object Has State State is a condition or situation during the life of
an object, which satisfies some condition, performs some activity, or waits for some event.
The state of an object normally changes over time.
Name: J ClarkEmployee ID: 567138Date Hired: July 25, 1991Status: TenuredDiscipline: FinanceMaximum Course Load: 3 classes
Name: J ClarkEmployee ID: 567138HireDate: 07/25/1991Status: TenuredDiscipline: FinanceMaxLoad: 3
Professor Clark
70
Example: Professor
There are a sequence of events before an instructor becomes a University professor. Assistant professor (achieves tenure by
producing a number of quality publications) Tenure/Associate professor Professor (based on seniority)
71
What Are State Machine Diagrams?
A state machine diagram models dynamic behavior.
It specifies the sequence of states in which an object can exist: The events and conditions that cause the object
to reach those states The actions that take place when those states
are reached
Assistant Professor
Tenured
72
Special States
The initial state is the state entered when an object is created. An initial state is mandatory. Only one initial state is permitted. The initial state is represented as a solid circle.
A final state indicates the end of life for an object. A final state is optional. A final state is indicated by a bull’s eye. More than one final state may exist.
Applied
73
What Are Events?
An event is the specification of a significant occurrence that has a location in time and space. An event is an occurrence of a stimulus that can
trigger a state transition. Example:
• Successful publication of numerous papers
TenuredAssistantProfessor
Event
74
What Are Transitions?
A transition is a change from an originating state to a successor state as a result of some stimulus. The successor state could possibly be the originating
state. A transition may take place in response to an
event. Transitions can be labeled with event names.
Transition Event Name
TenuredAssistantProfessor maxPapers
75
Example: State Machine
Hired
AssistantProfessor
Tenured
Professor
Applied
rejected
accepted
Hiatus
H
H
takeSabbatical
retired
maxPapers
seniority
return
76
Where Are We?
State machine diagrams Component diagrams Deployment diagrams
77
What Is a Component Diagram?
A diagram that shows the organizations and dependencies among components
ComponentA
<<component>>
ComponentC
<<component>>
ComponentB
<<component>>
ComponentD
<<component>>
78
What Is a Component?
A modular part of a system that hides its implementation behind a set of external interfaces. Part of a logical or physical system
It conforms to and provides the physical realization of a set of interfaces.
It specifies the physical dependency to interfaces it requires.
Provided InterfaceName
Required InterfaceName
<<component>>Component NameComponentName
<<component>>
79
Where Are We?
State machine diagrams Component diagrams Deployment diagrams
80
What Is a Deployment Diagram?
The deployment diagram shows: Configuration of processing nodes at run-time Communication links between these nodes Deployed artifacts that reside on them
81
What Is a Node?
Represents a run-time computational resource Generally has at least memory
and often processing capability.
Types: Device
• Physical computational resource with processing capability.
• May be nested Execution Environment
• Represent particular execution platforms
<<exe env>>EE Name
<<device>>Device Name
<<device>>Sub Device
Name
82
What Is a Connector?
A connector represents a: Communication mechanism
• Physical medium• Software protocol
<<application server>>Server
<<RS-232>>
<<100-T Ethernet>>
Connector
<<client workstation>>Console
<<client workstation>>Kiosk
83
Example: Deployment Diagram
<<legacy RDBMS>>Course Catalog
<<Campus LAN>>
<<Campus LAN>><<Campus LAN>>
<<application server>>Registration Server
<<client workstation>>PC
Billing System
<<legacy>>
0..2000
1
1
1
11
84
Example: Deployment Diagram with Processes
<<legacy RDBMS>>Course Catalog
<<Campus LAN>>
<<Campus LAN>><<Campus LAN>>
<<application server>>Registration Server
<<client workstation>>PC
Billing System
<<legacy>>
CourseCatalogSystemAccessCourseRegistrationProcessBillingSstemAccess
StudentApplication
0..2000
1
1
11
1