Post on 25-Dec-2015
transcript
UMLUML
OverviewOverview
UML Diagrams to be CoveredUML Diagrams to be Covered
• Class Diagrams• Use Case Diagrams• Collaboration Diagrams• Sequence Diagrams• Package Diagrams• Component Diagrams • Deployment Diagrams• Activity Diagrams • State Diagrams
• Class Diagrams• Use Case Diagrams• Collaboration Diagrams• Sequence Diagrams• Package Diagrams• Component Diagrams • Deployment Diagrams• Activity Diagrams • State Diagrams
Class DiagramsClass Diagrams
• Are the most fundamental UML Diagram.
• Describe the classes in the system, and the static relationships between classes.
• Class diagrams are used during Analysis, Design and Development.
• Are the most fundamental UML Diagram.
• Describe the classes in the system, and the static relationships between classes.
• Class diagrams are used during Analysis, Design and Development.
UML Class DiagramUML Class Diagram
DVD Movie VHS Movie Video Game
Rental Item{abstract}
Rental Invoice
1..*1
Customer
Checkout Screen
1
0..1
1
DVD Movie VHS Movie Video Game
Rental Item{abstract}
Rental Invoice
1..*1
Customer
Checkout Screen
0..1
1
Simple
Association
Class
Abstract
Class
Simple
Aggregation
Generalization
Composition
(Dependency)
Multiplicity
UML Class DiagramUML Class Diagram
Parts of a ClassParts of a Class
• Classes can have four parts– Name– Attributes– Operations– Responsibilities
• Classes can show visibility and types.
• All parts but the Name are optional.
• Classes can have four parts– Name– Attributes– Operations– Responsibilities
• Classes can show visibility and types.
• All parts but the Name are optional.
MyClassName
+SomePublicAttribute : SomeType
-SomePrivateAttribute : SomeType
#SomeProtectedAttribute : SomeType
+ClassMethodOne()
+ClassMethodTwo()
Responsibilities
-- can optionally be described here.
Object DiagramsObject Diagrams
• An Object is an instance of a class.
• Object names are underlined.
• Object diagrams are similar to class diagrams. Many of the same notations are used.
• Object diagrams capture instances of classes, and allow the dynamic relationships to be shown.
• An Object is an instance of a class.
• Object names are underlined.
• Object diagrams are similar to class diagrams. Many of the same notations are used.
• Object diagrams capture instances of classes, and allow the dynamic relationships to be shown.
ThisOne : MyClassName
+SomePublicAttribute : SomeType
-SomePrivateAttribute : SomeType
#SomeProtectedAttribute : SomeType
+ClassMethodOne()
+ClassMethodTwo()
Class and Object DiagramsClass and Object Diagrams
0..1
0..n
Customer Rental Item
Rents+name:string
+id:integer
+released:date
+id:integer
Joe: Customer Casablanca: Movie
+name:Joe Smith
+id:1667
+released:1942
+id:22340
Class Diagram
Object Diagram
Class Name
Object NameAttributes
Association Name
• Stereotypes, Tagged Values and Constraints extend the UML– Stereotypes are
shown using <<>>– Tagged Values and
Constraints are shown using { }
• Stereotypes, Tagged Values and Constraints extend the UML– Stereotypes are
shown using <<>>– Tagged Values and
Constraints are shown using { }
RentalContract
<<persistent>>
{version=1.1}
ListOfRentedItems
Customer {ordered by title}
Constraint
Tagged Value
Stereotype
Stereotypes, Tagged Values and Constraints
Stereotypes, Tagged Values and Constraints
Use CasesUse Cases
• Describe interactions between users and computer systems (both called actors) .
• Capture user-visible functions.
• Achieve discrete measurable goals.
• Are typically used during Analysis and Design.
• Describe interactions between users and computer systems (both called actors) .
• Capture user-visible functions.
• Achieve discrete measurable goals.
• Are typically used during Analysis and Design.
Use Case DiagramUse Case Diagram
Telephone Customer
In-StoreCustomer
Clerk
Identify Movie
Open Account
Return Movie
Customer
ReviewAccount Status
Actor
Use Case
Collaboration DiagramsCollaboration Diagrams
• Collaboration diagrams describe object interactions organized around the objects and their links to each other
• Focus on exchange of messages between objects through their associations.
• Appears during Analysis phase
• Enhanced during Design phase
• Collaboration diagrams describe object interactions organized around the objects and their links to each other
• Focus on exchange of messages between objects through their associations.
• Appears during Analysis phase
• Enhanced during Design phase
:Check-out Manager
:Customer
:Inventory
1: enter_customer()
3: enter_movies()
5: add(customer, movies)
7: print invoice() 2: IsValidCust(CustId)
4:GetMovieByBarcode()
Collaboration Diagram - Rent Movie
Collaboration Diagram - Rent Movie
:Clerk
Object
Message
:Rented Items
8: generateRentalTotal()
Sequence DiagramsSequence Diagrams
• Describe interactions between objects arranged in time sequence
• Focus on objects and classes involved in the scenario and the sequence of messages exchanged
• Associated with use cases• Used heavily during Analysis phase and
are enhanced and refined during Design phase
• Describe interactions between objects arranged in time sequence
• Focus on objects and classes involved in the scenario and the sequence of messages exchanged
• Associated with use cases• Used heavily during Analysis phase and
are enhanced and refined during Design phase
Sequence Diagram - Rent Movie
Sequence Diagram - Rent Movie
1: find customer()2: search (string)
4: search (string)
6: add(Cust, item)
3: enter movie()
5: rent (movie)
7: printInvoice() 8: generateRentalTotal()
Object
Lifeline
ActivationMessage
:CheckoutMgr :InventoryCust:Customer :RentedItems:Employee
Package DiagramPackage Diagram
Clerk User Interface
«facade»BusinessSystemClient
(to businesssystem )Custom er Data
Renta l ScreenClass
Package
Component DiagramComponent Diagram
«applica tion»V ideo
W orksta tion(vsta tion .exe)
« lib rary»D B S erverIn terface
(dbsvr.d ll)
Supplied byM icrosoft
«lib rary»A pplica tionFram ework(appfr.d ll)
Component
Interface
Dependency
Note
C heck O ut Term ina l:C lerk C lien t
P hone C lerk Term ina l:C lerk C lien t
:S tore S erver
S erverD B
S toreS erver
A pp«TC P /IP »
«TC P /IP »
Node
Communication
Association
Deployment DiagramDeployment Diagram
Identify Caller
Create Account
Obtain Name& Address
Open Account?Current
Customer? [no] [no]
[yes][yes]
Action State
Start State
Decision
End State
Activity DiagramActivity Diagram
Identify Movie
PlaceOrder
Place Order
FillOrder
Pay
DeliverMovie
PickupMovie
Customer Manager Walking Clerk
Fork Point
Join Point
CollectMoney
Swimlanes and Fork/Join PointsSwimlanes and Fork/Join Points
State DiagramState Diagram
Validate
do/checkaccount
custom er appears
Check-Out
do/check-outvideo
[account valid ]/get first video
[m ore videos]/get next video
Check-OutComplete
[no m ore videos]
[account notvalid]State
Transition
Activity
Guard
Action
Event