Upload
jodie-green
View
225
Download
1
Embed Size (px)
Citation preview
COP4331 1
Copyright © 1997 by Rational Software Corporation
Unified Modeling Language (UML)
Based on slides and papers from Rational’s UML website
http://www.rational.com/uml
COP4331 2
The Value of the UML
• Is an open standard
• Supports the entire software development lifecycle
• Supports diverse applications areas
• Is based on experience and needs of the user community
• Supported by many tools
COP4331 3
History of the UML
Booch ´91
Booch ´93
Unified Method 0.8
UML 1.0
OMT - 2
OMT - 1
OOSE
UML 0.9 & 0.91
OOPSLA ´95
June ´96 & Oct ´96
Sep ´97
Other methods
Jan ´97
Industry Feedback
UML 1.1
Nov ‘97UML approved by the OMG
COP4331 4
What is the UML?
• The UML is a language for visualizing, specifying, constructing, and documenting the artifacts of a software-intensive system
• Process and implementation independent– It can be used with a large number of
processes, throughout the development life cycle, and across OO implementation technologies
• The UML combines– Data Modeling concepts (Entity Relationship
Diagrams)
– Business Modeling (work flow)
– Object Modeling
– Component Modeling
• The de facto standard for OO systems
COP4331 5
The UML Usages
• Define the boundaries of a system & its major functions– use cases and actors
• Illustrate use cases– interaction diagrams
• Define the static structure of a system – class diagrams
• Model the behavior of objects– state transition diagrams
• Document the physical implementation architecture– component & deployment diagrams
• Provide for growth– stereotypes
COP4331 6
Modeling Elements
• Structural elements– class, interface, collaboration, use case, active
class, component, node
• Behavioral elements– interaction, state machine
• Grouping elements– package, subsystem
• Other elements– note
COP4331 7
DiagramsThe foundation of UML
• Use Case Diagrams– Requirements
• Activity Diagrams– Generally what, not who - good to detect
parallelism
• Interaction Diagrams– Sequence Diagrams (timeline)
– Collaboration Diagrams (object centered)
• Static Structure Diagrams – Objects/Classes/Packages
• Statechart Diagrams – States of objects with interesting lifecycles
• Implementation Diagrams– Component Diagrams
– Deployment Diagrams
COP4331 8
Actors
• An actor is someone or some thing that interacts with the system
• External Forces– Human interaction
– Automated System
KeyboardOperator
User
Driver
Traffic Control System
<<toll booth>>
<<Backup System>>
COP4331 9
Use Cases
• A use case is a pattern of behavior the system exhibits– Each use case is a sequence of related
transactions performed by an actor and the system in a dialogue
– Details what the system must provide to the actor when the use cases is executed
• A flow of events document is created for each use case– Written from an actor point of view– Actors are examined to determine their how
they interact with the systemBreak down into the most atomic actions
possible
• Typical contents– How the use case starts and ends– Normal flow of events– Alternate flow of events– Exceptional flow of events
COP4331 10
Use Case Diagram
• Captures system functionality as seen by users
• Built in early stages of development
• Purpose– Specify the context of a system
– Capture the requirements of a system
– Validate a system’s architecture
– Drive implementation and generate test cases
• Developed by analysts and domain experts
COP4331 11
Use Case Diagram
• Use case diagrams are created to visualize the relationships between actors and use cases
Passager
Mechanic
Driver
Lost Luggage
Ramp Maintenance
Pay toll
Customer Service Agent
COP4331 12
• Captures system functionality as seen by users
Use Case Diagram
COP4331 13
• As the use cases are documented, other use case relationships may be discovered– A uses relationship shows behavior
that is common to one or more use cases
– An extends relationship shows optional behavior
Ramp Agent
<<uses>>
Loose luggage<<uses>>
Baggage Handler
Uses and Extends Use Case Relationships
COP4331 14
Sequence Diagram
• A sequence diagram displays object interactions arranged in a time sequence
PassengerCounterAgent
Ticket GateAgent
1: Give Info
3: Answer4: Print
6:Present7: Board
9: Return
8: Overbook
2: Questions
Plane
5: Safeguard
COP4331 15
: Registrar
course form :
CourseForm
theManager : CurriculumManageraCourse :
Course
1: set course info2: process
3: add course
4: new course
Collaboration Diagram
• A collaboration diagram displays object interactions organized around objects and their links to one another
COP4331 16
Class Diagrams
• A class diagram shows the existence of classes and their relationships in the logical view of a system
• UML modeling elements in class diagrams– Classes and their structure and behavior
– Association, aggregation, dependency, and inheritance relationships
– Multiplicity and navigation indicators
– Role names
• Attributes– The structure of a class is represented by its
attributes
– Attributes may be found by examining class definitions, the problem requirements, and by applying domain knowledge
• Operations– The behavior of a class is represented by its
operations
– Operations may be found by examining interaction diagrams
COP4331 17
• Captures the vocabulary of a system
Class Diagram
COP4331 18
Relationships
• Relationships provide a pathway for communication between objects
• Sequence and/or collaboration diagrams are examined to determine what links between objects need to exist to accomplish the behavior -- if two objects need to “talk” there must be a link between them
• Three types of relationships are:– Association
– Aggregation
– Dependency
COP4331 19
Relationships
• An association is a bi-directional connection between classes– An association is shown as a line connecting
the related classes
• An aggregation is a stronger form of relationship where the relationship is between a whole and its parts– An aggregation is shown as a line connecting
the related classes with a diamond next to the class representing the whole
• A dependency relationship is a weaker form of relationship showing a relationship between a client and a supplier where the client does not have semantic knowledge of the supplier
• A dependency is shown as a dashed line pointing from the client to the supplier
COP4331 20
• 1 - one and only one
• 4 - four and only 4
• 0..1 - zero or 1
• 5..10 - five to and including 10
• 0..* - zero or more
• 4..* - four or more
Relationship Notation
COP4331 21
Registration
ManagerMath 101:
Course
3: add student(joe)
RegistrationManager
Course
Finding Relationships
• Relationships are discovered by examining interaction diagrams– If two objects must “talk” there must be a
pathway for communication
COP4331 22
RegistrationForm
RegistrationManager
Course
Student
CourseOffering
Professor
addStudent(Course, StudentInfo)
name
numberCredits
open()
addStudent(StudentInfo)name
major
location
open()
addStudent(StudentInfo)
name
tenureStatus
ScheduleAlgorithm
Relationships
COP4331 23
Multiplicity and Navigation
• Multiplicity defines how many objects participate in a relationships– Multiplicity is the number of instances of one
class related to ONE instance of the other class
– For each association and aggregation, there are two multiplicity decisions to make: one for each end of the relationship
• Although associations and aggregations are bi-directional by default, it is often desirable to restrict navigation to one direction
• If navigation is restricted, an arrowhead is added to indicate the direction of the navigation
COP4331 24
RegistrationForm
RegistrationManager
Course
Student
CourseOffering
Professor
addStudent(Course, StudentInfo)
name
numberCredits
open()
addStudent(StudentInfo)major
location
open()
addStudent(StudentInfo)
tenureStatus
ScheduleAlgorithm
10..*
0..*
1
1
1..*4
3..10
0..41
Multiplicity and Navigation
COP4331 25
Inheritance
• Inheritance is a relationships between a superclass and its subclasses
• There are two ways to find inheritance:– Generalization
– Specialization
• Common attributes, operations, and/or relationships are shown at the highest applicable level in the hierarchy
COP4331 26
RegistrationForm
RegistrationManager
Course
Student
CourseOffering
Professor
addStudent(Course, StudentInfo)
name
numberCredits
open()
addStudent(StudentInfo)major
location
open()
addStudent(StudentInfo)
tenureStatus
ScheduleAlgorithm
name
RegistrationUser
Inheritance
COP4331 27
The State of an Object
• A state transition diagram shows – The life history of a given class
– The events that cause a transition from one state to another
– The actions that result from a state change
• State transition diagrams are created for objects with significant dynamic behavior
COP4331 28
InitializationOpen
entry: Register student
exit: Increment count
Closed
Canceled
do: Initialize course
do: Finalize course
do: Notify registered students
Add Student /
Set count = 0
Add student[ count < 10 ]
[ count = 10 ]
Cancel
Cancel
Cancel
State Transition Diagram
COP4331 29
The Physical World
• Component diagrams illustrate the organizations and dependencies among software components
• A component may be – A source code component
– A run time components or
– An executable component
COP4331 30
Component Diagram
• Captures the physical structure of the implementation
COP4331 31
Deploying the System
• The deployment diagram shows the configuration of run-time processing elements and the software processes living on them
• The deployment diagram visualizes the distribution of components across the enterprise.
COP4331 32
• Captures the topology of a system’s hardware
Deployment Diagram
COP4331 33
Extensibility Mechanisms
• Stereotype
• Tagged value
• Constraint
COP4331 34
Extending the UML
• Stereotypes can be used to extend the UML notational elements
• Stereotypes may be used to classify and extend associations, inheritance relationships, classes, and components
• Examples:– Class stereotypes: boundary, control, entity,
utility, exception
– Inheritance stereotypes: uses and extends
– Component stereotypes: subsystem
COP4331 35
Real UML Use Case Diagram
COP4331 36
Real UML
COP4331 37
Real UML
COP4331 38
Real UMLClass Diagram
COP4331 39
Real UMLClass Diagram