Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 31

UML Diagrams

Ingrid Kirschning & Gerardo Ayala

UML Diagrams
Use Case Diagrams
Use Case diagrams & descriptions

Static Structure Diagrams


Class & object diagrams

Interaction Diagrams
Sequence & collaboration diagrams

State Diagrams
State diagrams & Activity diagrams (not in OMT nor Booch)

Implementation Diagrams
Package, Component & Deployment diagrams

Use Cases (Anwendungsfall)


Used to describe the main processes in a system and the interactions between the processes (use cases) and external systems or individuals called actors. Once the overview is developed it can be expanded to include subprocesses. The use case description is a generic scenario that is a series of sentences describing each step in the interaction between an actor and a use case.
System
Use Case Use Case

Actor (People)

Use Case

Actor (Systems)

Static Structure Diagrams


Class Diagram: shows classes & relationships
(Klassen-Diagramm & Beziehungen)
Class name

Class name

attribute attribute:primitiveDataType or Class attribute: type or Class=default value method method ( ) method (argument_list):type or Class

Attributes - (private) # (protected) + (public)

Methods - (private) # (protected) + (public)

<<Responsabilities>> Basic UML notation for classes

Text that describes what the object has to do

Modeling of the system


To model classes:
Identify their responsabilities Verify the balance between responsabilities (divide the classes with too many responsabilities & eliminate those with very few trivial responsabilities) Find the attributes and necesssary operations (methods) to accomplish those responsabilities. HW elements that contain SW : nodes

Associations
Associations document relations between two or more classes Association name Class A role_A role_B Class B

Order

Contains

Part

lineNumber:int made_up_of

included_in orderNumber:int

Multiplicity of Associations
Multiplicity: refers to how many objects of one class can relate to each object of another class.
Symbols used to indicate multiplicity in associations:
Class Class Class
*
0..1

Exactly one

Class
Zero or more Optional (0 or 1)

1..*

One or more Specific possibilities 1,2,3 or five objects Additional info

Class Class

1-3,5

* {ordered}

Class Inheritance & Specialization


Class name Methods
Class: Chairs [Attribute A1] Attribute B1 [Method A1] Method B1 Class: Executive Chairs [Attribute A1] [Attribute B1] Attribute C1 [Method A1] Method B1 (overriding) Method C1 Class: Furniture Attribute A1 Method A1

Attributes

Is a specialization of or Inherits from

Aggregation
Aggregation is a special type of association: a partwhole relationship - a class has an attribute which is an object of another class. Composition is a special case of aggregation where
1. The class is the only one that has objects of that class as attributes 2. This class is the only one that can create or destroy these objects. Composition: Class CD is the Class A CD Aggregation: CD only one with Class CD has MyDate objects, an attribute and the only one * of class Date that can create & Class B Date MyDate destroy them. (Date may appear as attribute of other classes, but not MyDate)

Constraints & Notes


Constraints are fuctional relationships between elements of a class, for example, limits on the values an attribute can take, limit the number of objects that can exist at any point of time, etc. Notes: explanation or more complex constraints
Association name Class A
{constraint on assoc.}

Class B Note on constraint Note about the class

Associations
Association Class: An association that has the properties of a class. Dependency Relationship: Indicates that one of the elements will change when the other changes. It is drawn with a dotted line.
Semester * Takes part Ternary association * Lecture
if grade <=4 then Pass=true

Student *

Result Pass:boolean

Object Diagrams
Objects are also represented in rectangles, their names underlined & written with first letter in small case. Names of objects can be written in 4 ways:
write only the class name preceded by a colon and underlined : Student write the name of specific object with its class oneStudent : Student write only the object name oneStudent: multiple objects : : Student

Object Diagrams
newCD:CD enterDate:Date

scienceL:Lecture :Student Takes part languageL:Lecture sportsL:Lecture artL:Lecture

Interaction Diagrams: Sequence & Collaboration Diagrams


They show how the objects cooperate sending messages to one another in order to perform a task. Provide a macro-level analysis of the dynamics of the system Approaches to diagramming:
Data-centric: Use case diagram Class diagram Sequence diagram Problem-centric: Use case diagram Sequence diagram Class diagram

Sequence Diagram (Reihenfolge-Diagramm)


Graphical way to illustrate a scenario They show the sequence in which objects pass messages to each other Message : request to an object to perform a method (invoke a method) They show when objects are created and destroyed

Sequence diagram notation (Reihenfolge-Diagramm)


(This is not an object) object: :Class Class object:

Event name Event (number) Notes on whats happening Outside the system Event {constraints} 3 min.

Event Event

Event

Outside the system

Sequence diagram notation (2)


(This isnt a SW object) object: :Class
Event (message name)

object: object:

Notes on whats happening Outside the system

Event Event Event (message name) Event {constraints} Outside the system

Example: Class Diagram


Student Transcript

* Course
Student studentName studentID listOfCoursesID transcript:Transcript setStudentName() getStudentName() setStudentID() getStudentID() addToListofCourseIDs() makeTranscript() Transcript studentName studentID listOfCourseNames lilstOfGrades average setStudentName() setStudentID() addCourseName() addGrade() calculateAverage() show()

Course courseName courseID grade readCourseData() readCourseGrade() setCourseID()

Example: MakeTranscript Sequence Diagram


<<somebody invokes makeTranscript() of object :Student >>
:Student
makeTranscript() <<create>>

:Transcript
<<for each Course in listofCourseID of object Student>>
setStudentID( ) setStudentName( ) <<create>> setCourseID( ) getGrade( ) courseName addCourseName( ) courseGrade addGrade ( ) <<destroy>> show ( ) calculateAvg( ) <<destroy>> readCourseGrade readCourseName

:Course

X X

<<Read-methods access a database>>

Collaboration Diagrams (Kooperations-Diagramme)


Provides a second way of showing the sequence in which events occur Objects are shown in rectangles connected by lines that indicate llinks between them. Numbers indicate the order in which the operation is executed. The numbers are written together with the message name and an arrow that indicates direction of flow.

Collaboration Diagram
: Class name
1: Message name

: Class name
2: Message name (parameter list)

object name: Class name attribute attribute = value

State Diagrams (Zustands-Diagramme)


State is a set of values that describe an object at a certain instant. State diagrams provide an exact view of what happens in one object when it receives successive messages. Not every class needs to have its state diagram only when they are very dynamic it is helpful for the understanding of all the possible states of an object and when a message would trigger each transition from one state to another.

State Diagrams
start stop

Initial state A

Event name

State B

Reserved actions: entry: a specific action performed on the entry to the state do: an ongoing action performed while in the state on: a specific action performed as a result of a specific event Exit: a specific action performed on exiting the state
State name State variables

State name
entry:entry-action do:activity-A on event-A: action-B exit: exit-action

State Diagram Example


enter PWD

CheckPWD do: compare PWD

OK

Instantiate :OwnerInfo

PWD unacceptable (repeat 2 times) PWD unacceptable (3rd. wrong entry)

UnacceptablePWD do: ask to repeat

Activity Diagrams (Aktivitten-Diagramme)


Activity diagrams model the flow of activities in a procedure States are called activities Events are called transitions State diagrams focus on events in one specific object as it responds to messages Activity diagrams are used to model the entire process or use-case The activity diagram describes the performance of a task and is not related to objects.

Activity Diagrams
start stop

Initial activity

Transition

Activity-B
Activity-C Activity-D

Decision

[Option A]

[Option B]

The bar shows that one activity leads to several that occur in parallel or in an unpredictable order.

Activity Diagrams Example


Check User PWD
PWD wrong 1st & 2nd time

PWD wrong 3rd time Access declined

Ask to repeat PWD Get new CD data

User Info is set

User chooses menu option

Get search criteria ......


.....

Implementation Diagrams
Package diagrams: allow developers to show how classes could be divided into modules. (They are logical diagrams) Component diagrams: used to show physical modules that a developer might use. Deployment diagrams: allow developers to model the physical platforms and network connections that will be usaed in their applications.

Package Diagrams
Packages are an organization of the defined classes into groups. They represent logical software modules. They use the same associations as ClassDiagrams (aggregation, association, generalization/specialization, Package A dependency,)

Package B

Package C

Component Diagrams (Komponenten-Diagramme)


Component is any form of software Component diagrams show software components and their relationships (dotted arrows) They show physical components from a high level view to show how code-modules are distributed. They are more often used together with deploymend diagrams and not separate.
Component A Component B

Deployment Diagrams (Einsatz-Diagramme)


Each node or processing element is represented by a 3D-box. The communication/relationships are represented with solid lines
PC
1 * Printer

1 Server

Fax PC
1

You might also like