uml - california polytechnic state university · pdf file• graphical notations •...
TRANSCRIPT
![Page 1: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/1.jpg)
UML
• Graphical notations
• Meta-model
• UML as sketch, blueprint, programming language
• MDA – PIM, PSM
• History – three amigos
• Tools – Visio, Dia, Violet
![Page 2: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/2.jpg)
Class Diagrams
• Classes, Interfaces
• Attributes, operations
– Visibility (+,-,#,~), multiplicity
• Associations: uni, bi-directional
• Dependencies
• Generalization, realization
• Constraints {} (DbC)
![Page 3: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/3.jpg)
More on Attributes
• Attribute Syntax:
– [visibility] name [multiplicity] [: type]
[= initial-value] [{property-string}]
– Examplespassword
- password
password : String
# password : String = “changeme”
+ password [1] : String
password : String {frozen}
![Page 4: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/4.jpg)
Visibility
• visibility:
+ for public, # for protected, - for private
• Public: Anything that can access the class can access this attribute or operation
• Protected: Any descendant of this class can access this attribute or operation
• Private: Only operations in this class can access this attribute or operation
![Page 5: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/5.jpg)
More on Attributes
• property-string options:
– changeable (default if left off)
• No restrictions on modifying the attribute’s value.
– addOnly
• If multiplicity is > 1, additional values may be
added, but once created, a value may not be removed or altered.
– frozen
• Attribute’s value cannot be changed after
initialization.
![Page 6: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/6.jpg)
More on Operations
• Operation Syntax:
– [visibility] name [(parameter-list)]
[: return type] [{property-string}]
– Examplesconnect
+ connect : Boolean
connect(name : String, password : String)
isConnected() : Boolean {isQuery}
getName (in ID : Integer, out name : String)
![Page 7: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/7.jpg)
More on Operations
• Operation Parameter Syntax:
– [direction] name : type [= default-value]
– direction: in, out, inout
– Example:
• # getPasswd(in ID : Integer, out passwd : String = “changeme”)
![Page 8: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/8.jpg)
More on Operations
• property-string options:
– leaf
• non-polymorphic; may not be overridden.
– isQuery
• causes no changes or side-effects to the system.
– sequential (valid only with active classes)
– guarded (valid only with active classes)
– concurrent (valid only with active classes)
![Page 9: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/9.jpg)
Class Relationships
• We have seen:
– uni- and bi-directional associations
– generalizations/subtypes/inheritance
• Now we will look at two more
forms of associations:
– aggregation
– composition
Employee
name
ID
<<type>>
0..*1
Time Sheet
start Date
end Date
Time Entries
Add Time Entry()
Submit()
Approve()
<<type>>
Employee
name
ID
<<type>>
ProjectManager
Employees Supervised : Employee List
getGroup()
<<type>>
![Page 10: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/10.jpg)
Aggregation
• whole-part relationship
• the “has-a” relationship
– Examples:
• A course has students.
• A song has notes.
![Page 11: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/11.jpg)
Aggregation
• The whole (aggregate) contains parts, but the parts may be in multiple aggregate classes
– Examples:
• A course has students.
– Students may be enrolled in several courses simultaneously.
• A song has notes.
– Several songs may use the same notes.
![Page 12: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/12.jpg)
Aggregation
• The whole (aggregate) contains parts, but destroying the whole does not destroy the parts and removing the parts does not have to destroy the whole
– Examples:
• A course has students.
– Deleting a course from the schedule does not delete the students.
• A song has notes.
– A song may have no notes. (John Cage 4’33’’)
![Page 13: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/13.jpg)
Aggregation
• What is the difference between an association and an aggregation?
– Officially there is no significant difference.
– An association may simply mean that one
class knows about another class.
– An aggregation implies that one class is made
up of other objects.
![Page 14: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/14.jpg)
Composition
• A stronger form of aggregation where
– the parts have the same lifetime as the whole.
• Or at least they die at the same time.
– a part can exist in only one whole.
– Examples:
• An OS process contains allocated memory.
• A document contains a signature.
![Page 15: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/15.jpg)
Example
Web Course
URL
Student
ProfessorCourse Schedule
AddCourse()
DeleteCourse()
Registrar
Course
ID
Name
Credit Hours
Classroom
Building
Room
Course Meeting
Day
Start Time
End Time
Destroying a Course
destroys the Course Meeting,
but not the Classroom.
![Page 16: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/16.jpg)
Class Relationships• Assume classes A and B are related as
follows:
– Subtype (Generalization/Inheritance):
• A is a kind of B
– Instance (Classification):
• A is an example of B
– Association:
• A knows about B
– Aggregation:
• A has a B
– Composition:
• A contains a B
![Page 17: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/17.jpg)
Sequence Diagrams
: Employee
: User
Interface
: Time Sheet
Server
: Time Sheet : Time Entry
Get Time Sheet( )
Get Time Sheet(String)
Display Time Sheet( )
Add Time Entry( )
Add Time Entry( )create
Display Time Sheet( )
Submit Time Sheet( )Submit( )
![Page 18: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/18.jpg)
Sequence Diagrams
• Vertical line is lifeline of the object
• Objects can be created
• Objects can invoke operations on themselves
• Conditions may be added
– Ex. [all Time Entries entered]
• Iterations can be indicated with *
• Return arrows are implicit or explicit
![Page 19: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/19.jpg)
Sequence Diagrams
• Objects can be deleted with an X
• Asynchronous messages can be created for use with multi-threading/processing.
– Half arrows indicate the method is invoked
and control is returned to the caller (no
blocking)
![Page 20: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/20.jpg)
Deployment View
• Describes physical network configurations
• Concerns the performance, throughput, fault-tolerance, availability, installation, and maintenance
• Uses Deployment Diagrams
UNIX Server
TimeTracking
Server
Database
Client PC
GUI
![Page 21: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/21.jpg)
Activity Diagrams
• Displays sequential behavior of a system
• supports conditional behavior
– branch and merge
• supports parallel behavior
– fork and join
• similar to state diagrams where states are activities
![Page 22: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/22.jpg)
Activity DiagramsSelect
Wallpaper
Order
Wallpaper Remove old wallpaper
[ old wallpaper ]
Patch and Sand Walls
[ else ]
Paint Sizing
Receive Wallpaper
Put Up
Wallpaper
Remove
paneling
[ paneling ]
![Page 23: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/23.jpg)
Activity DiagramsSelect
Wallpaper
Order Wallpaper
Remove old wallpaper
[ old wallpaper ]
Patch and Sand Walls
[ else ]
Paint Sizing
Receive
Wallpaper
Put Up Wallpaper
Remove paneling
[ paneling ]
Prepare Walls
States can be added to group
activities
![Page 24: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/24.jpg)
Activity Diagrams
Swimlanes can be added to display responsibilities
![Page 25: UML - California Polytechnic State University · PDF file• Graphical notations • Meta-model • UML as sketch, blueprint, programming language • MDA – PIM, PSM ... – flowcharting](https://reader031.vdocuments.mx/reader031/viewer/2022030423/5aaa846c7f8b9a95188e306a/html5/thumbnails/25.jpg)
Activity Diagrams
• Useful when– analyzing a use case
– understanding workflow
– flowcharting a complicated algorithm
– describing tasks in a multithreaded application