UML Course Day2 V2
UML Course Day2 V2
Fundamentals
Ing. Gerardo Padilla Zárate
Day 2
Course Outline
1. Course presentation P
2. OO Concepts Review P
3. Introduction to UML P
4. UML Views P
5. Tool Fundamental P
Course outline (cont..)
6. Structural diagrams
7. Behavior Diagram
8. Model Management Diagrams
9. UML during development process
10. UML and 4GL
11. Review and Critique
Review
Structural Diagrams
n Deployment Diagram
n Component Diagram
n Object Diagram
n Class Diagram
Object [omg]
n An entity with a well-defined boundary and
identity that encapsulates state and
behavior. State is represented by
attributes and relationships, behavior is
represented by operations, methods, and
state machines.
n An object is an instance of a class.
Object Diagram[omg]
n An object diagram is a graph of
instances, including objects and data
values. A static object diagram is an
instance of a class diagram;
n it shows a snapshot of the detailed state
of a system at a point in time. The use
of object diagrams is fairly limited, mainly
to show examples of data structures.
Class - Object
Objects
triangle: Polygon triangle
center = (0,0)
vertices = ((0,0),(4,0),(4,3))
borderColor = black
fillColor = white
:Polygon
triangle: Polygon
scheduler
Link
n A semantic connection among a tuple of
objects.
n An instance of an association.
Links
officer
Jill:Person
member
member
downhillSkiClub:Club Joe:Person
member
Chris:Person
officer
Structural Diagrams
n Deployment Diagram
n Component Diagram
n Object Diagram
n Class Diagram
Class [omg]
n A description of a set of objects that
share the same attributes, operations,
methods, relationships, and semantics.
n A class may use a set of interfaces to
specify collections of operations it provides
to its environment.
Class Diagram [omg]
n A class diagram is a graph of Classifier
elements connected by their various
static relationships.
n Note that a “class” diagram may also
contain interfaces, packages,
relationships, and even instances, such as
objects and links.
n “static structural diagram”
Classes
Window
{abstract,
Window author=Joe,
status=tested}
+size: Area = (100,100)
#visibility: Boolean = true
Window +default-size: Rectangle
#maximum-size: Rectangle
-xptr: XWindow*
size: Area
visibility: Boolean
+display ()
display () +hide ()
hide () +create ()
-attachXWindow(xwin:Xwindow*)
Classes: compartments with names
Reservation
operations
guarantee()
cancel ()
change (newDate: Date)
responsibilities
bill no-shows
match to available rooms
exceptions
invalid credit card
Relationships
n Association
n Adornments
¨ Multiplicity
¨ Roles
n Generalization
n Aggregation - Composition
n Dependency
Association [omg]
n A relationship between two or more
classifiers that involve connections
among their instances.
Example
Example (explained)
Adornments: Multiplicity
n A multiplicity item specifies the range of
allowable cardinalities that a set may
assume.
n Multiplicity specifications may be given for
roles within associations, parts within
composites, repetitions, and other
purposes.
n Format: lower-bound .. upper-bound
Adornments: Roles
n The named specific behavior of an entity
participating in a particular context.
n A role may be static (e.g., an association
end) or dynamic (e.g., a collaboration role).
Association Ends
vertex
1 3..∗
Contains
Polygon Point
{ordered}
1
GraphicsBundle
1
bundle color
texture
density
Generalization
n Generalization is the taxonomic
relationship between a more general
element (the parent) and a more specific
element (the child) that is fully consistent
with the first element and that adds
additional information. It is used for
classes, packages, use cases, and other
elements.
Generalization
Shape
Shape
Shared Target Style
Truck Sailboat
Aggregation
n A special form of association that
specifies a whole-part relationship
between the aggregate (whole) and a
component part.
Aggregation
Composition
n A form of aggregation which requires that a
part instance be included in at most one
composite at a time, and that the composite
object is responsible for the creation and
destruction of the parts.
n Composition may be recursive.
n Synonym: composite aggregation.
Composition (cont’d)
Window
2
scrollbar:Slider
1
title:Header
1
body:Panel
Composite objects
awindow : Window
horizontalBar:ScrollBar
verticalBar:ScrollBar
moves
surface:Pane
moves
title:TitleBar
Composition
Window
Window
1
1 1
«call» ClassC
«refine»
ClassC combines
two logical classes
ClassD ClassE
Review: Structural Diagrams:
Object and Class Diagrams
n What is an object diagram?
n What is a class diagram?
n What is a link?
n What is an association?
n What is an aggregation? Composition?
n What is a generalization?
n What is a dependency?
n Describe the adornment: multiplicity
n Describe the adornment: roles
Excercise 3
Part 1
n Make a class diagram that captures the following:
¨ A company consists of departments and employees. A
department has responsibility for zero, one or more projects. A
company has: name, address and telephone. A department has
name. A project has name. An employee has name, address, a
social security number (SSN) and is participating in zero, one or
more projects.
n Let the class diagram show: classes with attributes,
relations (with role names) between the classes and
multiplicity for the relations.
Part 2
n An object diagram is an instance of a class diagram,
typically showing a snap-shot of the system under
execution.
n An object diagram is showing objects (instances of
classes defined in the class diagram) with attributes and
links (instances of relations defined in the class diagram)
between objects.
n You can typically define many object diagrams given a
class diagram; make an object diagram that satisfies the
class diagram you just made (Part 1).
Part 3
n Extend the class diagram from Part 1 with the following:
¨ A project has a leader that is an employee.
¨ A company has one or more owners (juristic persons are not
considered); the system must keep track of the owners name, address
and social security number. The owner might be an employee or not!
¨ An employee is assigned to one or more departments in the company
that he works for.
For each assignment a title (e.g. programmer), salary (e.g. 410.000 kr.)
and extent is defined (e.g. an employee can work 25% for one
department and 75% for another department, the first assignment has
extent 25 and the last 75).
¨ Tax rate is given for each company the employee is working for (the tax
rate applies to all assignments in the same company). An employee
number is also recorded for each company the employee is working for.
Part 4
n Make an object diagram that satisfies the
class diagram you just made (Part 3)
Interfaces
Interface
n Collection of operations that
specify a service of a class or
component.
n Describes the EXTERNALLY
VISIBLE BEHAVIOR of a
component.
n Usually attached to a class or
other component.
Interfaces: Shorthand Notation
StoreHome Store
StoreHome Store
POSterminal +create()
<<use>> <<interface>> +login(UserName, Passwd)
POSterminal Store +find(StoreId)
+getPOStotals(POSid)
+getPOStotals(POSid) +updateStoreTotals(Id,Sales)
+updateStoreTotals(Id,Sales) +get(Item)
+get(Item)
Review: Interfaces
n What is an interface?
n Describe the two ways to visualize an
interface
Behavioral
Diagrams
Behavioral view
n A model aspect that emphasizes the
behavior of the instances in a system,
including their methods, collaborations,
and state histories.
n Behavior: The observable effects of an
operation or event, including its results.
What are interactions?
n Interaction: a collection of
communications between instances,
including all ways to affect instances, like
operation invocation, as well as creation
and destruction of instances
n The communications are partially ordered
(in time)
Interactions: Core Elements
Construct Description Syntax
Instance An entity with a unique identity and
(object, to which a set of operations can be name
n Kinds
¨ sequence diagram (temporal focus)
¨ collaboration diagram (structural focus)
Interaction Diagrams
Sequence Diagram Collaboration Diagram
x y z 1.1: a
1.2: c
a x y
b
1.1.1: b
c
z
Behavioral Diagrams
n Sequence Diagram
n Colaboration Diagram
n StateChart Diagram
n Activity Diagram
Sequence Diagram
n A diagram that shows object interactions
arranged in time sequence.
n In particular, it shows the objects participating in
the interaction and the sequence of messages
exchanged.
n Does not include object relationships.
n Sequence diagrams and collaboration diagrams
express similar information, but show it in
different ways.
Sequence Diagram: Change Flight Itinerary
Traveler : Booking System Client Account DBMS Airline Reservation System
change flight itinerary
get customer account
get itinerary
present itinerary
select segment
update information
available flight
:
:
Different Kinds of Arrows
Return
Sequence Diagram
object symbol name : Class other
lifeline
stimulus
name (…)
activation
new (…)
: Class
delete
return create
Example: A Java program: Hello
World!(1)
Example: A Java program: Hello
World!(2)
n HelloWorld is a sub-class of Applet.
n HelloWorld uses Graphics.
Example: A Java program: Hello
World!(3)
n Inheritance diagram
n Note reverse
engineering: these are
already implemented in
Java AWT.
n ImageObserver is an
interface. Has no
implementation, only
specification.
Example: A Java program: Hello
World!(4)
n How is the paint( ) operation invoked ?
Example: A Java program: Hello
World!(5)
n HelloWorld is an applet that is run through
an HTML page on the Web.
Review: Behavioral Diagrams:
Sequence Diagram
n What is a behavioral diagram?
n What is an interaction?
n What is a Sequence diagram?
n Describe the elements inside a SD:
¨Instance
¨Stimulus: Message
¨Object lifeline