Upload
hoa-le
View
218
Download
0
Embed Size (px)
Citation preview
8/13/2019 UML 2 Complete
1/83
SERG
Advanced Software Engineer ing
Unif ied Modeling Language(UML)
8/13/2019 UML 2 Complete
2/83
What is UML?
Standard language for specifying, visualizing,constructing, and documenting the artifacts ofsoftware systems, business modeling and other non-software systems.
The UML represents a collection of best engineeringpractices that have proven successful in themodeling of large and complex systems.
The UML is a very important part of developing objectoriented software and the software developmentprocess.
The UML uses mostly graphical notations to expressthe design of software projects.
Using the UML helps project teams communicate,explore potential designs, and validate thearchitectural design of the software.
8/13/2019 UML 2 Complete
3/83
Overview of UML Diagrams
Structural: element of spec. irrespective of time
Class
Component Deployment
Object
Composite structure
Package
Behavioral: behavioral features of a system / businessprocess
Activity
State machine
Use case
Interaction
Interaction: emphasize object interaction
Communication(collaberation)
Sequence
Interaction overview
Timing
8/13/2019 UML 2 Complete
4/83
SERGSoftware Design (UML)
Classes
ClassName
attributes
operations
A classis a description of a set ofobjects that share the same attributes,
operations, relationships, and semantics.
Graphically, a class is rendered as arectangle, usually including its name,
attributes, and operations in separate,
designated compartments.
8/13/2019 UML 2 Complete
5/83
SERGSoftware Design (UML)
Class Names
ClassName
attributes
operations
The name of the class is the only required
tag in the graphical representation of a
class. It always appears in the top-most
compartment.
8/13/2019 UML 2 Complete
6/83
SERGSoftware Design (UML)
Class Attributes
Person
name : String
address : Addressbirthdate : Date
ssn : Id
An attributeis a named property of a
class that describes the object being modeled.
In the class diagram, attributes appear in
the second compartment just below the
name-compartment.
8/13/2019 UML 2 Complete
7/83 SERGSoftware Design (UML)
Class Attributes (Contd)
Person
name : String
address : Addressbirthdate : Date
/ age : Date
ssn : Id
Attributes are usually listed in the form:
attributeName : Type
A derivedattribute is one that can be
computed from other attributes, butdoesnt actually exist. For example,
a Persons age can be computed from
his birth date. A derived attribute is
designated by a preceding / as in:
/ age : Date
8/13/2019 UML 2 Complete
8/83 SERGSoftware Design (UML)
Class Attributes (Contd)
Person
+ name : String
# address : Address# birthdate : Date
/ age : Date
- ssn : Id
Attributes can be:
+ public
# protected
- private
/ derived
8/13/2019 UML 2 Complete
9/83 SERGSoftware Design (UML)
Class Operations
Person
name : String
address : Addressbirthdate : Date
ssn : Id
eat
sleepwork
play
Operations describe the class behavior
and appear in the third compartment.
8/13/2019 UML 2 Complete
10/83 SERGSoftware Design (UML)
Class Operations (Contd)
PhoneBook
newEntry (n : Name, a : Address, p : PhoneNumber, d : Description)
getPhone ( n : Name, a : Address) : PhoneNumber
You can specify an operation by stating its signature: listing the
name, type, and default value of all parameters, and, in the case of
functions, a return type.
8/13/2019 UML 2 Complete
11/83 SERGSoftware Design (UML)
Depicting Classes
Person
name : String
birthdate : Date
ssn : Id
eat()
sleep()
work()
play()
When drawing a class, you neednt show attributes and operationin every diagram.
Person
Person
name
address
birthdate
Person
eat
play
Person
8/13/2019 UML 2 Complete
12/83 SERGSoftware Design (UML)
Class Responsibilities
A class may also include its responsibilities in a class diagram.
A responsibility is a contract or obligation of a class to perform
a particular service.
SmokeAlarm
Responsibilities
-- sound alert and notify guard stationwhen smoke is detected.
-- indicate battery state
8/13/2019 UML 2 Complete
13/83 SERGSoftware Design (UML)
Relationships
In UML, object interconnections (logical or physical), are
modeled as relationships.
There are three kinds of relationships in UML:
dependencies
generalizations
associations
8/13/2019 UML 2 Complete
14/83 SERGSoftware Design (UML)
Dependency Relationships
CourseSchedule
add(c : Course)
remove(c : Course)
Course
A dependencyindicates a semantic relationship between two ormore elements. The dependency from CourseScheduleto
Courseexists because Courseis used in both the addand
removeoperations of CourseSchedule.
8/13/2019 UML 2 Complete
15/83 SERGSoftware Design (UML)
Generalization Relationships
PersonAgeneralizationconnects a subclass
to its superclass. It denotes an
inheritance of attributes and behaviorfrom the superclass to the subclass and
indicates a specialization in the subclass
of the more general superclass.Student
8/13/2019 UML 2 Complete
16/83
8/13/2019 UML 2 Complete
17/83 SERGSoftware Design (UML)
Association Relationships
If two classes in a model need to communicate with each other,there must be link between them.
An associationdenotes that link.
InstructorStudent
8/13/2019 UML 2 Complete
18/83 SERGSoftware Design (UML)
Association Relationships (Contd)
We can indicate the multiplicityof an association by addingmultiplicity adornmentsto the line denoting the association.
The example indicates that a Studenthas one or more
Instructors:
InstructorStudent1..*
8/13/2019 UML 2 Complete
19/83
8/13/2019 UML 2 Complete
20/83
SERGSoftware Design (UML)
Association Relationships (Contd)
We can also indicate the behavior of an object in an association(i.e.,the role of an object) using rolenames.
InstructorStudent1..*1..*
learns fromteaches
8/13/2019 UML 2 Complete
21/83
SERGSoftware Design (UML)
Association Relationships (Contd)
We can also name the association.
TeamStudentmembership
1..* 1..*
8/13/2019 UML 2 Complete
22/83
SERGSoftware Design (UML)
Association Relationships (Contd)
We can specify dual associations.
TeamStudent
member of
1..*
president of1 1..*
1..*
8/13/2019 UML 2 Complete
23/83
SERGSoftware Design (UML)
Association Relationships (Contd)
We can constrain the association relationship by defining the
navigabilityof the association. Here, aRouterobject requests
services from aDNSobject by sending messages to (invoking
the operations of) the server. The direction of the association
indicates that the server has no knowledge of theRouter.
Router DomainNameServer
8/13/2019 UML 2 Complete
24/83
SERGSoftware Design (UML)
Association Relationships (Contd)
Associations can also be objects themselves, called linkclasses
or an association classes.
WarrantyProduct
Registration
modelNumber
serialNumber
warrentyCode
8/13/2019 UML 2 Complete
25/83
SERGSoftware Design (UML)
Association Relationships (Contd)
A class can have aself association.
LinkedListNode
next
previous
8/13/2019 UML 2 Complete
26/83
SERGSoftware Design (UML)
Association Relationships (Contd)
We can model objects that contain other objects by way of
special associations called aggregationsand compositions.
An aggregationspecifies a whole-part relationship between an
aggregate (a whole) and a constituent part, where the part can
exist independently from the aggregate. Aggregations aredenoted by a hollow-diamond adornment on the association.
Car
Engine
Transmission
8/13/2019 UML 2 Complete
27/83
SERGSoftware Design (UML)
Association Relationships (Contd)
A composition indicates a strong ownership and coincident
lifetime of parts by the whole (i.e.,they live and die as a
whole). Compositions are denoted by a filled-diamond
adornment on the association.
Window
Scrollbar
Titlebar
Menu
1
1
1
1
1
1 .. *
8/13/2019 UML 2 Complete
28/83
8/13/2019 UML 2 Complete
29/83
SERGSoftware Design (UML)
Interface Services
Interfaces do not get instantiated.
They have no attributes or state.
Rather, they specify the servicesoffered by a related class.
ControlPanel
getChoices : Choice[]
makeChoice (c : Choice)
getSelection : Selection
8/13/2019 UML 2 Complete
30/83
SERGSoftware Design (UML)
Interface Realization Relationship
ControlPanel
VendingMachine
A realizationrelationship
connects a class with an
interface that supplies its
behavioral specification. It is
rendered by a dashed line witha hollow triangle towards the
specifier.
specifier
implementation
8/13/2019 UML 2 Complete
31/83
SERGSoftware Design (UML)
Interfaces
A class interface can also be
rendered by a circleconnected to a class by a
solid line.
File
outputStream
inputStream
FileWriter{file must not be locked}
FileReader{file must exist}
8/13/2019 UML 2 Complete
32/83
SERGSoftware Design (UML)
Parameterized Class
LinkedList
T
T
1 .. *
Aparameterized classor
templatedefines a family of
potential elements.
To use it, the parameter must bebound.
A template is rendered by a small
dashed rectangle superimposed on
the upper-right corner of the classrectangle. The dashed rectangle
contains a list of formal parameters
for the class.
8/13/2019 UML 2 Complete
33/83
SERGSoftware Design (UML)
Parameterized Class (Contd)
LinkedList
T
T1..*
Bindingis done with the
stereotype and a parameter to
supply to the template. These are
adornments to the dashed arrow
denoting the realization
relationship.
Here we create a linked-list of
names for the Deans List.
DeansList
(Name)
8/13/2019 UML 2 Complete
34/83
SERGSoftware Design (UML)
Enumeration
Boolean
false
true
An enumerationis a user-defined
data type that consists of a name and
an ordered list of enumeration
literals.
8/13/2019 UML 2 Complete
35/83
SERGSoftware Design (UML)
Exceptions
KeyException
SQLException
Exception
getMessage()printStackTrace()
Exceptionscan be modeled
just like any other class.
Notice the
stereotype in the namecompartment.
8/13/2019 UML 2 Complete
36/83
SERGSoftware Design (UML)
Package Diagram
Compiler
Apackageis a container-like element
for organizing other elements into
groups.
A package can contain classes andother packages and diagrams.
Packages can be used to provide
controlled access between classes in
different packages.
8/13/2019 UML 2 Complete
37/83
SERGSoftware Design (UML)
Packages (Contd)
Classes in theFrontEndpackage and classes in theBackEndpackage cannot access each other in this diagram.
FrontEnd BackEnd
Compiler
8/13/2019 UML 2 Complete
38/83
SERGSoftware Design (UML)
Packages (Contd)
Classes in theBackEndpackage now have access to the classesin theFrontEndpackage.
FrontEnd BackEnd
Compiler
8/13/2019 UML 2 Complete
39/83
8/13/2019 UML 2 Complete
40/83
8/13/2019 UML 2 Complete
41/83
SERGSoftware Design (UML)
Component Diagram
collision.dll
driver.dllversion= 8.1.3.2
path.dll
IDrive
ISelfTest
Heres an example of a component
model of an executable release.
[Booch,99]
8/13/2019 UML 2 Complete
42/83
8/13/2019 UML 2 Complete
43/83
SERGSoftware Design (UML)
Deployment Diagram
Deployment diagrams are one of the two kinds of diagramsfound in modeling the physical aspects of an object-oriented
system. They show the configuration of run-time processing
nodes and the components that live on them.
Use deployment diagrams to model the static deploymentviewof a system. This involves modeling the topology of the
hardware on which the system executes.
- The UML User Guide, [Booch,99]
8/13/2019 UML 2 Complete
44/83
SERGSoftware Design (UML)
Deployment Diagram
A component is a physical unit of implementation with well-defined interfaces that is intended to be used as a replaceable
part of a system. Well designed components do not depend
directly on other components, but rather on interfaces that
components support.
- The UML Reference Manual, [Rumbaugh,99]
spell-check
Dictionarysynonyms
component
interfaces
8/13/2019 UML 2 Complete
45/83
SERGSoftware Design (UML)
Deployment Diagram
UpdateTransactions
Account
[Rumbaugh,99]
ATM-GUI
component
realization dependency
interface
usage dependency
stereotypedcomponent
8/13/2019 UML 2 Complete
46/83
8/13/2019 UML 2 Complete
47/83
SERGSoftware Design (UML)
Software Design
Dynamic Modeling using the
Unif ied Modeling Language(UML)
8/13/2019 UML 2 Complete
48/83
SERGSoftware Design (UML)
Use Case
A use casespecifies the behavior of a system or a part of asystem, and is a description of a set of sequences of actions,
including variants, that a system performs to yield an observable
result of value to an actor.
- The UML User Guide, [Booch,99]
An actoris an idealization of an external person, process, or
thing interacting with a system, subsystem, or class. An actor
characterizes the interactions that outside users may have with
the system.- The UML Reference Manual, [Rumbaugh,99]
8/13/2019 UML 2 Complete
49/83
8/13/2019 UML 2 Complete
50/83
SERGSoftware Design (UML)
Use Case (Contd)
An actor is rendered as a stick
figure in a use case diagram.
Each actor participates in one ormore use cases.
Student
8/13/2019 UML 2 Complete
51/83
SERGSoftware Design (UML)
Use Case (Contd)
Student Person
Actors can participate in a generalization relation with other
actors.
8/13/2019 UML 2 Complete
52/83
SERGSoftware Design (UML)
Use Case (Contd)
Register for Courses
Actors may be connected to use cases
only by associations.
Student
8/13/2019 UML 2 Complete
53/83
SERGSoftware Design (UML)
Use Case (Contd)
Student
Billing System
Registrar
Register for Courses
Here we have a Studentinteracting with theRegistrarand the
Billing Systemvia a Register for Courses use case.
8/13/2019 UML 2 Complete
54/83
SERGSoftware Design (UML)
State Machine
The state machine view describes the dynamic behavior of
objects over time by modeling the lifecycles of objects of each
class. Each object is treated as an isolated entity that
communicates with the rest of the world by detecting events and
responding to them. Events represent the kinds of changes that
objects can detect... Anything that can affect an object can becharacterized as an event.
- The UML Reference Manual, [Rumbaugh,99]
8/13/2019 UML 2 Complete
55/83
SERGSoftware Design (UML)
State Machine
An object must be in some specific state at any given time during
its lifecycle. An object transitions from one state to another as the
result of some event that affects it. You may create a state
diagram for any class, collaboration, operation, or use case in a
UML model .
There can be only one start state in a state diagram, but there may
be many intermediate and final states.
8/13/2019 UML 2 Complete
56/83
SERGSoftware Design (UML)
State Machine
start state final state
simple state
concurrent composite state
sequential composite state
h
8/13/2019 UML 2 Complete
57/83
SERGSoftware Design (UML)
State Machine
selecting
verifying
downloading
checking schedule
download course offerings
make a course selection
verify selection
check schedule
select another course
make a different selection
unscheduled
scheduled
sign schedule
S
8/13/2019 UML 2 Complete
58/83
SERGSoftware Design (UML)
Sequence Diagram
Asequence diagramis an interaction diagram that emphasizes
the time ordering of messages. It shows a set of objects and the
messages sent and received by those objects.
Graphically, a sequence diagram is a table that shows objects
arranged along the X axis and messages, ordered in increasingtime, along the Y axis.
- The UML User Guide, [Booch,99]
S D
8/13/2019 UML 2 Complete
59/83
SERGSoftware Design (UML)
Sequence Diagram
An object in a sequence diagram is rendered
as a box with a dashed line descending from it.
The line is called the object lifeline, and itrepresents the existence of an object over a
period of time.
an Order Line
S Di
8/13/2019 UML 2 Complete
60/83
SERGSoftware Design (UML)
Sequence Diagram
an Order Line a Stock Item
[check = true]
remove()
check()
Messages are rendered as horizontal
arrows being passed from object to
object as time advances down theobject lifelines. Conditions ( such as
[check = true] ) indicate when a
message gets passed.
S Di
8/13/2019 UML 2 Complete
61/83
SERGSoftware Design (UML)
Sequence Diagram
an Order Line a Stock Item
[check = true]
remove()
check()
Notice that the bottom arrow is different.
The arrow head is not solid, and there isno accompanying message.
This arrow indicates a returnfrom aprevious message, not a new message.
8/13/2019 UML 2 Complete
62/83
8/13/2019 UML 2 Complete
63/83
C i i /C ll b i Di
8/13/2019 UML 2 Complete
64/83
SERGSoftware Design (UML)
Communication/Collaboration Diagram
A collaboration diagram emphasizes the relationship of theobjects that participate in an interaction. Unlike a sequence
diagram, you dont have to show the lifeline of an object
explicitly in a collaboration diagram. The sequence of events are
indicated by sequence numbers preceding messages.
Object identifiers are of the form objectName : className,and
either the objectName or the className can be omitted, and the
placement of the colon indicates either an objectName: , or a
:className.
C ll b ti Di
8/13/2019 UML 2 Complete
65/83
SERGSoftware Design (UML)
Collaboration Diagram
: Order Entry Window
: Order
: Order Line
:Delivery Item
: Stock Item
:Reorder Item
1: prepare()
2*: prepare() 3: check()4: [check == true] remove()
6: new7: [check == true] new
5: needToReorder()
[Fowler,97]
Self-Delegation
Object
Message
Sequence Number
Collaboration Diagram
8/13/2019 UML 2 Complete
66/83
SERGSoftware Design (UML)
gSequence Diagram
Both a collaboration diagram and a sequence diagram derive
from the same information in the UMLs metamodel, so you can
take a diagram in one form and convert it into the other. Theyare semantically equivalent.
A ti it Di
8/13/2019 UML 2 Complete
67/83
SERGSoftware Design (UML)
Activity Diagram
An activity diagram is essentially a flowchart, showing theflow of control from activity to activity.
Use activity diagrams to specify, construct, and document the
dynamics of a society of objects, or to model the flow of
control of an operation. Whereas interaction diagramsemphasize the flow of control from object to object, activity
diagrams emphasize the flow of control from activity to
activity. An activity is an ongoing non-atomic execution
within a state machine.
- The UML User Guide, [Booch,99]
[Fowler 97]ReceiveOrder
8/13/2019 UML 2 Complete
68/83
SERGSoftware Design (UML)
[Fowler,97]Order
AuthorizePayment
CheckLineItem
CancelOrder
Assign toOrder
ReorderItem
Dispatch
Order
[failed]
[succeeded] [in stock]
* for each lineitem on order
[need toreorder]
[stock assigned toall line items and
payment authorized]
Synchronization Condition
Multiple Trigger
8/13/2019 UML 2 Complete
69/83
8/13/2019 UML 2 Complete
70/83
Object diagram
8/13/2019 UML 2 Complete
71/83
Package diagram
UML 2 Package diagramssimplifycomplex class diagrams, it can groupclasses into p k ges. A package is acollection of logically related UMLelements. Packages are depicted as filefolders and can be used on any of the
UML diagrams.
http://www.agilemodeling.com/essays/umlDiagrams.htmhttp://www.agilemodeling.com/essays/umlDiagrams.htm8/13/2019 UML 2 Complete
72/83
Package diagram
8/13/2019 UML 2 Complete
73/83
Composite structure diagram
UML 2 Composite structure diagramsused to explore run-time instances ofinterconnected instances collaborating
over communications links. It shows theinternal structure (including parts andconnectors) of a structured classifier or
collaboration.
http://www.agilemodeling.com/essays/umlDiagrams.htmhttp://www.agilemodeling.com/essays/umlDiagrams.htm8/13/2019 UML 2 Complete
74/83
Composite structure diagram
8/13/2019 UML 2 Complete
75/83
8/13/2019 UML 2 Complete
76/83
Timing diagram
8/13/2019 UML 2 Complete
77/83
Timing diagram
8/13/2019 UML 2 Complete
78/83
Interaction overview diagram
UML 2 Interaction overview diagramsfocuses on the overview of the flow ofcontrol of the interactions. It is a variant
of the Activity Diagram where the nodesare the interactions or interactionoccurrences. It describes the
interactions where messages andlifelines are hidden.
http://www.agilemodeling.com/essays/umlDiagrams.htmhttp://www.agilemodeling.com/essays/umlDiagrams.htm8/13/2019 UML 2 Complete
79/83
Interaction overview diagram
8/13/2019 UML 2 Complete
80/83
Interaction overview diagram
UML di hi h
8/13/2019 UML 2 Complete
81/83
UML diagram hierarchy
References
http://upload.wikimedia.org/wikipedia/commons/6/6f/Uml_hierarchie_des_diagrammes.png8/13/2019 UML 2 Complete
82/83
SERGSoftware Design (UML)
References
[Booch99] Booch, Grady, James Rumbaugh, Ivar Jacobson,
The Unified Modeling Language User Guide, Addison Wesley
The Unified Modeling Language Reference Manual
The Unified Software Development Process
UML Distilled (Applying the Standard Object Modeling Language)
http://www.agilemodeling.com/
http://www.visual-paradigm.com/VPGallery/diagrams/index.html
http://bdn.borland.com/article/0,1410,31863,00.html
http://en.wikipedia.org/wiki/Unified_Modeling_Language
http://pigseye.kennesaw.edu/~dbraun/csis4650/A&D/UML_tutorial/index.htm
8/13/2019 UML 2 Complete
83/83
THANK YOU