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
Deployment Diagram n Component Diagram n Object Diagram n Class Diagram
n

Object [omg]
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.
n

Object Diagram[omg]
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.
n

Class - Object

Objects
triangle: Polygon
center = (0,0) vertices = ((0,0),(4,0),(4,3)) borderColor = black fillColor = white

triangle

:Polygon

triangle: Polygon

scheduler

Link
A semantic connection among a tuple of objects. n An instance of an association.
n

Links
officer Jill:Person member downhillSkiClub:Club member Joe:Person

member Chris:Person officer

Structural Diagrams
Deployment Diagram n Component Diagram n Object Diagram n Class Diagram
n

Class [omg]
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.
n

Class Diagram [omg]
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”
n

Classes
Window Window {abstract, author=Joe, status=tested} +size: Area = (100,100) #visibility: Boolean = true +default-size: Rectangle #maximum-size: Rectangle -xptr: XWindow* +display () +hide () +create () -attachXWindow(xwin:Xwindow*)

Window size: Area visibility: Boolean display () hide ()

Classes: compartments with names
Reservation
operations

guarantee() cancel () change (newDate: Date)
responsibilities

bill no-shows match to available rooms
exceptions

invalid credit card

Relationships
Association n Adornments
n
¨ Multiplicity ¨ Roles

Generalization n Aggregation - Composition n Dependency
n

Association [omg]
n

A relationship between two or more classifiers that involve connections among their instances.

Example

Example (explained)

Adornments: Multiplicity
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
n

Adornments: Roles
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).
n

Association Ends
1 Polygon 1 1 bundle GraphicsBundle color texture density vertex 3..∗ Contains Point {ordered}

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 Vehicle

MotorPowered Vehicle

Land Vehicle

Water 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

n 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. Composition may be recursive. Synonym: composite aggregation.

Composition (cont’d)
Window scrollbar:Slider 2

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 scrollbar Slider 2 1 1 title

1 Header

body

1 Panel

Dependency
n

n

n

A dependency indicates a semantic relationship between two model elements (or two sets of model elements). It relates the model elements themselves and does not require a set of instances for its meaning. 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 «friend» ClassB «friend» «instantiate » ClassD operationZ()

«call»

ClassC

«refine»

ClassC combines two logical classes

ClassD

ClassE

Review: Structural Diagrams: Object and Class Diagrams
n n n n n n n n n

What is an object diagram? What is a class diagram? What is a link? What is an association? What is an aggregation? Composition? What is a generalization? What is a dependency? Describe the adornment: multiplicity 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

n

n

An object diagram is an instance of a class diagram, typically showing a snap-shot of the system under execution. 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. 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
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.
n

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

Interfaces: Longhand Notation

StoreHome POSterminalHome POSterminal <<use>> POSterminal <<interface>> Store +getPOStotals(POSid) +updateStoreTotals(Id,Sales) +get(Item)

Store -storeId: Integer -POSlist: List +create() +login(UserName, Passwd) +find(StoreId) +getPOStotals(POSid) +updateStoreTotals(Id,Sales) +get(Item)

Review: Interfaces
n n

What is an interface? Describe the two ways to visualize an interface

Behavioral Diagrams

Behavioral view
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.
n

What are interactions?
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)
n

Interactions: Core Elements
Construct
Instance (object, data value, component instance etc.) Action

Description
An entity with a unique identity and to which a set of operations can be applied (signals be sent) and which has a state that stores the effects of the operations (the signals). A specification of an executable statement. A few different kinds of actions are predefined, e.g. CreateAction, CallAction, DestroyAction, and UninterpretedAction.

Syntax
name attr values

textual

Interaction: Core Elements
(cont’d)
Construct
Stimulus Operation

Description
A communication between two instances. A declaration of a service that can be requested from an instance to effect behavior. A specification of an asynchronous stimulus communicated between instances.

Syntax

textual

Signal

«Signal» Name parameters

Interaction: Core Relationships
Construct
Link

Description
A connection between instances.

Syntax

Attribute Link A named slot in an instance, which holds the value of an attribute.

textual

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
x a b 1.1.1: b c z y z x

Collaboration Diagram
1.1: a 1.2: c y

Behavioral Diagrams
Sequence Diagram n Colaboration Diagram n StateChart Diagram n Activity Diagram
n

Sequence Diagram
n n

n n

A diagram that shows object interactions arranged in time sequence. In particular, it shows the objects participating in the interaction and the sequence of messages exchanged. Does not include object relationships. Sequence diagrams and collaboration diagrams express similar information, but show it in different ways.

Sequence Diagram: Change Flight Itinerary
Traveler : Booking System change flight itinerary get customer account get itinerary present itinerary select segment present detailed info update information available flight Client Account DBMS Airline Reservation System

: :

Different Kinds of Arrows
Procedure call or other kind of nested flow of control

Return

Sequence Diagram
object symbol lifeline
name (…) name : Class other

stimulus

activation

new (…) : Class

delete

return

create

Example: A Java program: Hello
World!(1)

Example: A Java program: Hello
World!(2)
HelloWorld is a sub-class of Applet. n HelloWorld uses Graphics.
n

Example: A Java program: Hello
World!(3)
n n

n

Inheritance diagram Note reverse engineering: these are already implemented in Java AWT. 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 n n n

What is a behavioral diagram? What is an interaction? What is a Sequence diagram? Describe the elements inside a SD:
¨Instance ¨Stimulus:

Message ¨Object lifeline

Sign up to vote on this title
UsefulNot useful