uml diagrams ingrid kirschning & gerardo ayala. uml diagrams use case diagrams –use case...

31
UML Diagrams Ingrid Kirschning & Gerardo Ayala

Upload: mavis-murphy

Post on 29-Dec-2015

313 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

UML Diagrams

Ingrid Kirschning & Gerardo Ayala

Page 2: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

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

Page 3: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

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.

Actor (People) Actor (Systems)

Use Case

Use Case

Use Case

System

Page 4: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Static Structure Diagrams• Class Diagram: shows classes &

relationships(Klassen-Diagramm & Beziehungen)

Class nameAttributes- (private)# (protected)+ (public)

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

Class name

attributeattribute:primitiveDataType or Classattribute: type or Class=default value

methodmethod ( )method (argument_list):type or Class

Basic UML notation for classes

<<Responsabilities>>Text that describes what the object has to do

Page 5: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

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

Page 6: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Associations

Class A Class Brole_A role_B

Association name

OrderlineNumber:int

Part orderNumber:int made_up_of included_in

Contains

Associations document relations between two or more classes

Page 7: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

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

ClassClass

ClassClass

Class

Exactly one

Zero or more*

0..1 Optional (0 or 1)

1..*

1-3,5

* {ordered}

One or more

Specific possibilities1,2,3 or five objects

Additional info

Page 8: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Class Inheritance & SpecializationClass: Furniture

Attribute A1Method A1

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 name Attributes

Methods

Is a specialization ofor

Inherits from

Page 9: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Aggregation• Aggregation is a special type of association: a part-whole

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 attributes2. This class is the only one that can create or destroy these objects.

Date

CD Aggregation:Class CD has an attribute of class Date

MyDate

CD

Composition:Class CD is the only one with MyDate objects, and the only one that can create & destroy them.

*Class B

Class A

(Date may appear as attribute of other classes, but not MyDate)

Page 10: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

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

Class A Class B{constraint on assoc.}

Association name

Note on constraint

Note aboutthe class

Page 11: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

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.

if grade <=4 then Pass=true

Student

Semester

Lecture

ResultPass:boolean

*

*

*Takes part

Ternary association

Page 12: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

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 it’s classoneStudent : Student

– write only the object name oneStudent:

– multiple objects :: Student

Page 13: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Object Diagrams

:Student Takes part languageL:Lecture

scienceL:Lecture

sportsL:Lecture

artL:Lecture

enterDate:Date

newCD:CD

Page 14: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

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

Page 15: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

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

Page 16: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Sequence diagram notation(Reihenfolge-Diagramm)

object: :Class Class object:

Outside the system

Event name

Event (number)

Event3 min.

EventEvent

Event

{constraints}Notes on what´s happening

Outside the system

(This is not an object)

Page 17: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Sequence diagram notation (2)

object: :Class

object:

object:

Outside the system

Event (message name)

Event

Event

Event (message name)

{constraints}

Notes on what´s happening

Outside the system

Event

X

(This isn´t a SW object)

Page 18: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Student Transcript

Course

*

StudentstudentName

studentIDlistOfCoursesID

transcript:TranscriptsetStudentName()getStudentName()

setStudentID()getStudentID()

addToListofCourseIDs()makeTranscript()

TranscriptstudentName

studentIDlistOfCourseNames

lilstOfGradesaverage

setStudentName()setStudentID()

addCourseName()addGrade()

calculateAverage()show()

CoursecourseName

courseIDgrade

readCourseData()readCourseGrade()

setCourseID()

Example: Class Diagram

Page 19: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Example: “MakeTranscript” Sequence Diagram

<<for each Course in listofCourseID of object Student>>

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

:Student

:Transcript

:Course

makeTranscript()

X

<<create>>

setStudentID( )setStudentName( )

<<create>>

setCourseID( )

getGrade( )

courseName

courseGrade

readCourseName

readCourseGrade

<<Read-methods access a database>>

addCourseName( )

addGrade ( )

<<destroy>>

show ( )calculateAvg( )

<<destroy>> X

Page 20: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

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.

Page 21: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Collaboration Diagram

: Class name : Class name

object name: Class name

attribute

attribute = value

1: Message name

2: Message name(parameter list)

Page 22: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

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.

Page 23: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

State Diagrams

Initial state AEvent name

State Bstart stop

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 name

State variables

entry:entry-actiondo:activity-Aon event-A: action-Bexit: exit-action

Page 24: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

State Diagram Example

CheckPWDdo: compare PWD

Instantiate:OwnerInfo

UnacceptablePWDdo: ask to repeat

OK

PWD unacceptable(repeat 2 times)

PWD unacceptable(3rd. wrong entry)

enter PWD

Page 25: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Activity Diagrams (Aktivitäten-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.

Page 26: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Activity Diagrams

Initial activityTransition

Activity-Bstart stop

Decision [Option A]

[Option B]

Activity-C

Activity-D

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

Page 27: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Activity Diagrams Example

Check User PWD

User Info is setUser chooses menu option

.....

Ask to repeat PWDPWD wrong

3rd timeAccess declined

Get new CD data

Get search criteria

......

PWD wrong 1st & 2nd time

Page 28: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

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.

Page 29: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Package Diagrams• Packages are an organization of the defined

classes into groups.

• They represent logical software modules.

• They use the same associations as Class-Diagrams (aggregation, association, generalization/specialization, dependency,…)

Package A

Package B Package C

Page 30: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

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

Page 31: UML Diagrams Ingrid Kirschning & Gerardo Ayala. UML Diagrams Use Case Diagrams –Use Case diagrams & descriptions Static Structure Diagrams –Class & object

Deployment Diagrams(Einsatz-Diagramme)

• Each node or processing element is represented by a 3D-box.

• The communication/relationships are represented with solid lines

PC1

PC1

Server1

Printer*

Fax*