0% found this document useful (0 votes)
197 views

UML Course Day2 V2

This document outlines a course on UML fundamentals. It includes an introduction to UML, its views and tools. It covers structural diagrams like class, object, component and deployment diagrams. It also discusses behavior diagrams and model management diagrams. The document defines key UML concepts like object, class, association and relationships. It provides examples of classes, objects, links and diagrams. It reviews structural diagrams and relationships like generalization, aggregation and composition.

Uploaded by

api-3760859
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
197 views

UML Course Day2 V2

This document outlines a course on UML fundamentals. It includes an introduction to UML, its views and tools. It covers structural diagrams like class, object, component and deployment diagrams. It also discusses behavior diagrams and model management diagrams. The document defines key UML concepts like object, class, association and relationships. It provides examples of classes, objects, links and diagrams. It reviews structural diagrams and relationships like generalization, aggregation and composition.

Uploaded by

api-3760859
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

UML

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

Separate Target Style

Polygon Ellipse Spline

Shape
Shared Target Style

Polygon Ellipse Spline


Generalization
Vehicle

WindPowered MotorPowered Land Water


Vehicle Vehicle Vehicle Vehicle

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

scrollbar [2]: Slider


title: Header
body: Panel

Window
1
1 1

scrollbar 2 title 1 body 1


Slider Header Panel
Dependency
n A dependency indicates a semantic
relationship between two model elements (or
two sets of model elements).
n It relates the model elements themselves and
does not require a set of instances for its
meaning.
n It indicates a situation in which a change to the
target element may require a change to the
source element in the dependency.
Dependencies
ClassA ClassB ClassD
«friend»
«friend»
operationZ()
«instantiate »

«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

POSterminalHome -storeId: Integer


-POSlist: List
POSterminal <<use>> +create()
+login(UserName, Passwd)
POSterminal +find(StoreId)
+getPOStotals(POSid)
Store +updateStoreTotals(Id,Sales)
+get(Item)
Interfaces: Longhand Notation

StoreHome Store

POSterminalHome -storeId: Integer


-POSlist: List

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

data value, applied (signals be sent) and which attr values

component has a state that stores the effects of


instance the operations (the signals).
etc.)

Action A specification of an executable textual


statement.
A few different kinds of actions are
predefined, e.g. CreateAction,
CallAction, DestroyAction, and
UninterpretedAction.
Interaction: Core Elements
(cont’d)
Construct Description Syntax
Stimulus A communication between two
instances.

Operation A declaration of a service that can textual


be requested from an instance to
effect behavior.

Signal A specification of an asynchronous «Signal»


Name
stimulus communicated between
parameters
instances.
Interaction: Core Relationships

Construct Description Syntax


Link A connection between instances.

Attribute Link A named slot in an instance, which textual


holds the value of an attribute.
Interaction Diagrams
n Show interactions between instances in
the model
¨ graph of instances (possibly including links)
and stimuli
¨ existing instances
¨ creation and deletion of instances

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

present detailed info

update information
available flight

:
:
Different Kinds of Arrows

Procedure call or other


kind of nested flow of
control

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

You might also like