UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you...

30
UML: Unified Modeling Language Story: What UML is for Some of the main diagrams are and what you use them for Class diagrams and class forms Use Case Diagrams Sequence (Event) Diagram State Diagrams An example

Transcript of UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you...

Page 1: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

UML: Unified Modeling Language

Story: What UML is for Some of the main diagrams are and what you

use them forClass diagrams and class formsUse Case DiagramsSequence (Event) DiagramState Diagrams

An example

Page 2: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

UML: Unified Modeling Language

Developed by the “Three Amigos”: Grady Booch, Jim Rumbaugh, Ivar Jacobson Each had their own development methodology More or less emphasis on notation and process

UML is a notation and a process Diagrams and notation from UML 1.3 Definition

(http://www.rational.com)

Page 3: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Diagrams

Class diagrams: Represents static structure

Use case diagrams: Sequence of actions a system performs to yield an observable result to an actor

Sequence diagrams:Shows how groups of objects interact in some behavior

State diagrams: Describes behavior of system by describing states of an object

Page 4: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Class Diagrams

Better name: “Static structure diagram” Doesn’t describe temporal aspects Doesn’t describe individual objects: Only the

overall structure of the systemThere are “object diagrams” where the boxes

represent instances But rarely used—other diagrams serve the role of

describing object interaction better When used, object diagrams describe static

structure, like a data structure

Page 5: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Different Levels of Specifying Classes

Page 6: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Notation in Class Boxes

Abstract classes (and operations) in italics+ is public, - is private, # is protectedCan also specify stereotypes or

compartments “constructors” or “query” “controller”

Page 7: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Other variations in Class specifications

Use of templates, interfaces, and types

Can even specify body of methods

Page 8: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Components of Class Diagrams

Multiplicities How many of

each?Labels to

indicate how reference is viewed

Role and Association classes

Page 9: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Navigability and Aggregations

Navigability Who owns/contains/has who? Arrows not strictly required

Aggregation: Open diamond “Part-of” relationship, but disagreement

Composition:closed diamond Part can only

belong to whole

Page 10: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Qualifiers

Serves to describe an instance variable that partitions the relationship.

Page 11: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Use Case Diagrams

Means of capturing requirementsDocument interactions between user(s)

and the system User (actor) is not part of the system itself But an actor can be another system

An individual use case represents a task to be done with support from the system (thus it is a ‘coherent unit of functionality’)

Page 12: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Simple Use Case Diagram

Reserve bookReserve book

Borrow bookBorrow book

Return bookReturn book

Page 13: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Use Case Diagram with Multiple Actors

Page 14: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Use Cases

Are actually defined as text, including descriptions of all of the normal and exception behavior expected

Do not reveal the structure of the systemCollectively define the boundaries of the

system to be implementedProvide the basis for defining

development iterations

Page 15: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Example Use Case Diagram (Advanced Features)

Page 16: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Sequence (Event) Diagrams

Shows individual objects and how they interact

Describes Lifelines of objects Who sends what messages when Can also describe sending messages to self

("self-delegation") Can describe guards, notes, etc.

Page 17: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Example Sequence Diagram

Page 18: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

State Diagrams

Describe all the possible states a particular object can get into, and the events that lead to those changes

Also called a "statechart"

Page 19: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Example State Diagram

Page 20: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Other Kinds of UML Diagrams

Collaboration Diagrams An alternative to sequence diagrams for

describing the flow of messages between objects

Page 21: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Other kinds of UML Diagrams

Activity Diagrams Alternative to

statecharts

Page 22: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Other kinds of UML Diagrams

Implementation Diagrams Down at the detail

levelWhat piece of code

goes where?How are they

connected?

Page 23: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

UML in Real Practice

You don't typically use all the diagrams You'll choose between them based on preference and

particular situation

You typically use many diagrams A single use case may not capture all scenarios If you are going to use statecharts, there are probably

lots of objects with states Each sequence/collaboration diagram only shows one

interaction

Page 24: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Example: Student Registration System

Not going to do all the diagrams Not all types, not even all that completely

specify the system

But this is an application you know, so the examples may help make sense

Page 25: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Student Registration Class Diagram

*

prereqs

0..30..30..3

prereqs

0..30..30..3

Course

namenumberdepartmentcreditHoursprerequisites

1

*****1

CourseGrade

coursegradetermEnrolled

Transcript

courseGrades

gradeForCourse:takenCourse:

1 ***

1

******

1..3 ******

*

111111

Department

coursesrequiredCourses

111Student

transcriptmajor

enrollInClass:gradeInCourse:takenCourse:

SectionSection

coursedaysAndTimedaysAndTimeroster

addStudentaddStudent

removeStudentremoveStudent **

1** sectionssections

Registrar

courses

getSectionsFor:getSectionsFor:

enrollInSection:enrollInSection:

dropFromSection:dropFromSection:

schedulescheduleregistrarregistrar

1**

1

Page 26: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Partial Use Case Diagram

Withdrawfrom a Course

Apply forAdmission

Student

Enroll inthe University

Enroll ina Course

Admissions

Page 27: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

States of a Student

EnrollInClass ( Add a Transcript )

EnrolledApply [ Must be accepted first ]

Graduate [ All courses must be completed ]

AddCourseRegisteredWithdraw

Page 28: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Sequence Diagram: Registering for Course

theRegistrar aSection theTranscriptaStudent

state of prereqhave prereq

enrolled

enrollInSection:

return sections

getSectionsFor:

addStudent:

enrolled

takenCourse: prerequisite

takenCourse: prerequisite

Page 29: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

Process to Representations

OOA CRC Cards (but they’re not officially UML) Use Cases

OOD Just about all of the rest But variations—some detail is later

OOP Can actually go UML->code with some tools!

Page 30: UML: Unified Modeling Language zStory: yWhat UML is for ySome of the main diagrams are and what you use them for xClass diagrams and class forms xUse Case.

UML v1.3 Copyright Notice

Copyright © 1997, 1998, 1999 Object Management Group, Inc.Copyright © 1997, 1998, 1999 Hewlett-Packard CompanyCopyright © 1997, 1998, 1999 IBM CorporationCopyright © 1997, 1998, 1999 ICON ComputingCopyright © 1997, 1998, 1999 i-LogixCopyright © 1997, 1998, 1999 IntelliCorpCopyright © 1997, 1998, 1999 Electronic Data Services CorporationCopyright © 1997, 1998, 1999 Microsoft CorporationCopyright © 1997, 1998, 1999 ObjecTime LimitedCopyright © 1997, 1998, 1999 Oracle CorporationCopyright © 1997, 1998, 1999 Platinum Technology, Inc.Copyright © 1997, 1998, 1999 Ptech Inc.Copyright © 1997, 1998, 1999 Rational Software CorporationCopyright © 1997, 1998, 1999 Reich TechnologiesCopyright © 1997, 1998, 1999 SofteamCopyright © 1997, 1998, 1999 Sterling SoftwareCopyright © 1997, 1998, 1999 Taskon A/SCopyright © 1997, 1998, 1999 Unisys Corporation