46
Using UML, Patterns, and Java Object-Oriented Software Engineering Art for Chapter 2, Modeling with UML

Art for Chapter 2, Modeling with UML

  • Upload
    kenyon

  • View
    28

  • Download
    0

Embed Size (px)

DESCRIPTION

Art for Chapter 2, Modeling with UML. SimpleWatch. ReadTime. SetTime. WatchUser. WatchRepairPerson. ChangeBattery. Figure 2-1, A UML use case diagram describing the functionality of a simple watch. SimpleWatch. 1. 1. 1. 1. 2. 1. 2. 1. PushButton. Display. Battery. Time. - PowerPoint PPT Presentation

Citation preview

Page 1: Art for Chapter 2, Modeling with UML

Usi

ng U

ML

, Pat

tern

s, a

nd J

ava

Ob

ject

-Ori

ente

d S

oftw

are

En

gin

eeri

ng Art for Chapter 2,

Modeling with UML

Page 2: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 2

WatchUser WatchRepairPerson

ReadTime

SetTime

ChangeBattery

SimpleWatch

Figure 2-1, A UML use case diagram describing the functionality of a simple watch.

Page 3: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 3

Figure 2-2, A UML class diagram describing the elements of a simple watch.

12

11

11

12

SimpleWatch

Display Battery TimePushButton

Page 4: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 4

Figure 2-3, A UML sequence diagram for the SimpleWatch.

:SimpleWatch :Time:Display

pressButton1() blinkHours()

blinkMinutes()

pressButton2() incrementMinutes()

refresh()

pressButtons1And2()commitNewTime()

stopBlinking()

pressButton1()

:WatchUser

Page 5: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 5

button1&2Pressed

button1Pressed

button2Pressed

button2Pressed

button2Pressed

button1Pressed

button1&2Pressed IncrementMinutes

IncrementHours

BlinkHours

BlinkSeconds

BlinkMinutes

IncrementSeconds

StopBlinking

Figure 2-4, A UML statechart diagram for SetTime use case of the SimpleWatch.

Page 6: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 6

OpenIncident

AllocateResources

CoordinateResources

DocumentIncident

ArchiveIncident

Figure 2-5, An example of a UML activity diagram.

Page 7: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7

Airplane

All blueprints

Scale model

Electrical

Fuel

Flight simulator

Figure 2-6, A Model is an abstraction describing a subset of a System. A View depicts selected aspects of a Model. Views and Models of a single System may overlap each other.

Page 8: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 8

Book ChapterN

composed-of

Booch

Book Chapter

composed-of

UML1 *

Figure 2-7, Example of describing a model with two different notations.

Page 9: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 9

Watch

timedate

CalculatorWatchSetDate(d)

EnterCalcMode()InputNumber(n)

calculatorState

Figure 2-8, A UML class diagram depicting two classes: Watch and CalculatorWatch. CalculatorWatch is a refinement of Watch, providing calculator functionality normally not found in normal Watches.

Page 10: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10

OrganicCompound

Benzene

Figure 2-9, An example of abstract class.

Page 11: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 11

Watch

CalculatorWatch

simpleWatch1291:Watch

calculatorWatch1515:CalculatorWatch

«instanceOf»

«instanceOf»

Figure 2-10, A UML class diagram depicting instances of two classes.

Page 12: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12

pressButton2() getTime()

getTimeDelta()

:WatchUser

GMTTime

GMTTime

:SimpleWatch :TimeZone:Time

Figure 2-11, Examples of message sends.

Page 13: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13

Application Domain Solution DomainApplication Domain Model System Model

AircraftTrafficController

FlightPlan Airport

MapDisplay

FlightPlanDatabase

SummaryDisplay

TrafficControl

TrafficControl

Figure 2-12, The application domain model represents entities of the environment which are relevant to an air traffic control system (e.g., aircraft, traffic controllers).

Page 14: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14

Report Emergency

FieldOfficer DispatcherOpenIncident

AllocateResources

FRIEND

Figure 2-13, An example of a UML use case diagram: Incident initiation in an accident management system.

Page 15: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15

OpenIncident

AllocateResources

HelpDispatcher«include»

«include»

Figure 2-16, An example of an «include» relationship.

Page 16: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16

Figure 2-18, An example of an «extend» relationship.

OpenIncident

AllocateResources

ConnectionDown «extend»

«extend»

Page 17: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 17

Authenticate

Authenticate

Authenticate WithPassword

WithCard

Figure 2-20, An example of a generalization relationship.

Page 18: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 18

EmergencyReport Incident

FieldOfficer

name:StringbadgeNumber:Integer

Dispatcher

name:StringbadgeNumber:Integer

author

incidentsGeneratedreportsGenerated

initiator

reports

1

*

1

*1..*

1

Figure 2-22, An example of a UML class diagram: classes that participate in the ReportEmergency use case.

Page 19: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 19

report_1291 incident_1515bob:FieldOfficer

name = “Bob D.”badgeNumber = 132

john:Dispatcher

name = “John D.”badgeNumber = 12

alice:FieldOfficer

name = “Alice W.”badgeNumber = 23

Figure 2-23, An example of a UML object diagram: objects that participate in the warehouseOnFire scenario.

Page 20: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 20

Figure 2-24, Example of a one-directional association.

Polygon Point**

Page 21: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 21

IncidentFieldOfficer

name:StringbadgeNumber:Integer

Allocates

role:StringnotificationTime:Time

resourcesincident

1

1..*

Figure 2-25, An example of an association class.

Page 22: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 22

Incident

FieldOfficer

name:StringbadgeNumber:Integer

Allocation

role:StringnotificationTime:Time

resources

incident 1

1..*

11

Figure 2-26, Alternative model for Allocation.

Page 23: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 23

* *

PoliceStation*

*

1

1

1

1State

Directory

County

PoliceOfficer

File

Township

Figure 2-27, Examples of aggregations.

Page 24: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 24

Figure 2-28, Examples of multiplicity.

FieldOfficer IncidentReport**

FireUnit FireTruck*1

PoliceOfficer11

owner property

author report

BadgeNumber

Page 25: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 25

Figure 2-29, Example of a hierarhical file system.

Directory

FileSystemElement

File

1

*

Page 26: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 26

Figure 2-30, Example of a nonhierarchical file system.

Directory

FileSystemElement

File

*

*

Page 27: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 27

Figure 2-31, Example of how a qualified association uses reduces multiplicity.

Directory Filefilename

DirectoryFile

filename

1Without qualification

With qualification

*

0..11

Page 28: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 28

EmergencyReport Incident

FieldOfficer Dispatcherauthor initiator

reportsGenerated incidents

1

*1

*

1..*

1

PoliceOfficer

name:StringbadgeNumber:Integer

Figure 2-32, An example of a generalization.

Page 29: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 29

Incident

assignResource(r)close()

Figure 2-33, Examples of operations provided by the Incident class.

Page 30: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 30

:SimpleWatch :Time:Display

pressButton1() blinkHours()

blinkMinutes()

pressButton2() incrementMinutes()

refresh()

pressButtons1And2()commitNewTime()

stopBlinking()

pressButton1()

:WatchUser

Figure 2-34, Example of a sequence diagram: setting the time on 2Bwatch.

Page 31: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 31

a b c

[i>0] op1()

[i<=0] op2()

*op3()

Figure 2-35, Examples of conditions and iterators in sequence diagrams.

Page 32: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 32

Figure 2-36, Example of a collaboration diagram: Setting the time on 2Bwatch.

:2BwatchInput

:2BwatchTime

:2BwatchDisplay

1:p ressButtons1And2()

1.1: blinkHours()

3.1:i ncrementMinutes()

3.2:r efresh()

4.1:commitNewTime()

:2BwatchOwner

2:pressButton1()3:pressButton2()4:pressButtons1And2()

2.1:blinkMinutes()4.2:stopBlinking()

Page 33: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 33

Active Inactive Closed Archived

incidentHandled incidentDocumented incidentArchived

Figure 2-37, A UML statechart diagram for the Incident class.

Page 34: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 34

MeasureTime SetTime

pressButtonsLAndR

pressButtonsLAndR/beep

after 2 min.

DeadBattery

after 20 yearsafter 20 years

Figure 2-38, Statechart diagram for 2Bwatch set time function.

Page 35: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 35

Figure 2-39, Internal transitions associated with the SetTime state.

SetTime

entry/blink hours

exit/stop blinking

pressButton1/blink next numberpressButton2/increment current number

MeasureTime

do/count ticks

MeasureTime

pressBothButtons

pressBothButtons/beep

after 2 min.

after 20 yearsafter 20 years

Page 36: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 36

SetTime

BlinkHours BlinkMinutes BlinkSeconds

BlinkYear BlinkMonth BlinkDay

b2/incr hour b2/incr min. b2/incr sec.

b2/incr year b2/incr mo. b2/incr day

b1

b1

b1

b1

b1b1

Figure 2-40, Refined statechart associated with the SetTime state.

Page 37: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 37

DocumentIncident

ArchiveIncident

HandleIncident

Figure 2-41, A UML activity diagram for Incident.

Page 38: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 38

[fire & highPriority]

[not fire & highPriority]

[lowPriority]

NotifyFire Chief

OpenIncident

NotifyPolice Chief

AllocateResources

Figure 2-42, Example of decision in the OpenIncident process.

Page 39: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 39

ArchiveIncident

OpenIncident

DocumentIncident

AllocateResources

CoordinateResources

Figure 2-43, An example of complex transitions in a UML activity diagram.

Page 40: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 40

ArchiveIncident

Dispatcher

FieldOfficer

OpenIncident

DocumentIncident

AllocateResources

CoordinateResources

Figure 2-44, An example of swimlanes in a UML activity diagram.

Page 41: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 41

Report Emergency

FieldOfficer

DispatcherOpenIncident

AllocateResources

ArchiveIncident

SearchArchive

ManageUsers

ManageTerminalsLibrarian SysAdmin

SysAdministrationIncidentArchive

IncidentManagement

Figure 2-45, Example of packages: use cases of FRIEND organized by actors.

Page 42: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 42

FieldOfficer Dispatcher

Librarian SysAdmin

IncidentArchive SysAdministration

IncidentManagement

Figure 2-46, Example of packages.

Page 43: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 43

DispatcherStation

EmergencyReport Incident

FieldOfficer Dispatcher

FieldStation

Figure 2-47, Example of packages.

Page 44: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 44

EmergencyReport

DispatcherStation

Incident

FieldOfficer Dispatcher

FieldStation

The EmergencyReportclass is defined in FieldStationand used in both stations.

Figure 2-48, An example of a note. Notes can be attached to a specific element in a diagram.

Page 45: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 45

«entity»

«entity»

«boundary»

«boundary»

«control»Year

Month

ChangeDateControl

LCDDisplayBoundary

ButtonBoundary

«entity»Day

Figure 2-49, Examples of stereotypes.

Page 46: Art for Chapter 2, Modeling with UML

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 46

EmergencyReport Incidentreports

1..*

{ordered by time of receipt}

Figure 2-50, An example of constraint.

1