Introduction To Software Engineering: UML: Ananda Amatya Department of Computer Science University of Warwick
Introduction To Software Engineering: UML: Ananda Amatya Department of Computer Science University of Warwick
Introduction To Software Engineering: UML: Ananda Amatya Department of Computer Science University of Warwick
Ananda Amatya
Department of Computer Science
University of Warwick
1.1.1 Commentary . . . . . . . . . . . . . 29
1.2.1 Commentary . . . . . . . . . . . . . 31
1.3 Introduction . . . . . . . . . . . . . . . . . . 32
1.3.1 Commentary . . . . . . . . . . . . . 33
1.4 Notation . . . . . . . . . . . . . . . . . . . . 34
1.4.1 Commentary . . . . . . . . . . . . . 35
1.5.1 Commentary . . . . . . . . . . . . . 37
3
4 CONTENTS
1.6.1 Commentary . . . . . . . . . . . . . 39
1.7.1 Commentary . . . . . . . . . . . . . 41
1.9.1 Commentary . . . . . . . . . . . . . 44
1.10.1 Commentary . . . . . . . . . . . . . 46
1.11 Specification . . . . . . . . . . . . . . . . . 47
1.12.1 Commentary . . . . . . . . . . . . . 49
1.13.1 Commentary . . . . . . . . . . . . . 51
1.14.1 Commentary . . . . . . . . . . . . . 53
CONTENTS 5
1.15 Diagrams . . . . . . . . . . . . . . . . . . . 54
1.15.1 Commentary . . . . . . . . . . . . . 55
1.16.1 Commentary . . . . . . . . . . . . . 57
1.17.1 Commentary . . . . . . . . . . . . . 59
1.18.1 Commentary . . . . . . . . . . . . . 61
1.19.1 Commentary . . . . . . . . . . . . . 63
1.20.1 Commentary . . . . . . . . . . . . . 65
1.21.1 Commentary . . . . . . . . . . . . . 67
1.25 Views . . . . . . . . . . . . . . . . . . . . . 71
1.26.1 Commentary . . . . . . . . . . . . . 73
1.37 Commentary . . . . . . . . . . . . . . . . . 84
2.2 Commentary . . . . . . . . . . . . . . . . . 91
2.3 Introduction . . . . . . . . . . . . . . . . . . 92
2.4 Commentary . . . . . . . . . . . . . . . . . 93
2.5 Actor . . . . . . . . . . . . . . . . . . . . . . 94
2.6 Commentary . . . . . . . . . . . . . . . . . 95
3.103Commentary . . . . . . . . . . . . . . . . . 244
3.105Commentary . . . . . . . . . . . . . . . . . 246
3.107Commentary . . . . . . . . . . . . . . . . . 248
3.109Commentary . . . . . . . . . . . . . . . . . 250
3.111Commentary . . . . . . . . . . . . . . . . . 252
3.114Commentary . . . . . . . . . . . . . . . . . 260
3.126Commentary . . . . . . . . . . . . . . . . . 274
3.128Commentary . . . . . . . . . . . . . . . . . 276
3.131Links . . . . . . . . . . . . . . . . . . . . . . 279
3.148Commentary . . . . . . . . . . . . . . . . . 296
3.149Transitions . . . . . . . . . . . . . . . . . . 297
3.150Commentary . . . . . . . . . . . . . . . . . 298
3.152Commentary . . . . . . . . . . . . . . . . . 300
3.154Commentary . . . . . . . . . . . . . . . . . 302
3.156Commentary . . . . . . . . . . . . . . . . . 304
3.158Commentary . . . . . . . . . . . . . . . . . 306
3.163Commentary . . . . . . . . . . . . . . . . . 311
3.164State . . . . . . . . . . . . . . . . . . . . . . 312
3.165Commentary . . . . . . . . . . . . . . . . . 313
3.167Commentary . . . . . . . . . . . . . . . . . 315
3.169Transitions . . . . . . . . . . . . . . . . . . 317
22 CONTENTS
3.170Commentary . . . . . . . . . . . . . . . . . 319
3.176Commentary . . . . . . . . . . . . . . . . . 325
3.181Commentary . . . . . . . . . . . . . . . . . 330
3.209Collaboration . . . . . . . . . . . . . . . . . 363
3.212Mechanisms . . . . . . . . . . . . . . . . . 366
3.214Frameworks . . . . . . . . . . . . . . . . . . 368
26 CONTENTS
Chapter 1
27
28 CHAPTER 1. LECTURE 0: INTRODUCTION TO UML
Recommended Books
Introduction
Notation
Diagrams
Views
OOSD
Requirements
Analysis
Design
Implementation
1.1. UML INTRODUCTION TOPICS 29
1.1.1 Commentary
1.2.1 Commentary
Booch et. al.’s book is the most authoritative and follows the
1.3 standard. It is conceptually quite hard at places. Some
examples are rather sketchy, and language bindings (Java
or C++) are touched upon only briefly. Quite expensive (
40 U. K. Pounds).
1.3 Introduction
1.3.1 Commentary
1.4 Notation
Modelling Elements:
– Basic elements
– Composite elements
– Relationships between elements
– States and Interactions
– Annotations
Modelling Mechanisms:
– Adornments
– Specifications
Modelling Rules
– Stereotypes
– Tagged Values
– Constraints
1.4. NOTATION 35
1.4.1 Commentary
Basic:
– Class
– Object
– Interface
– Collaboration
– Use Case
– Active Class
– Component
– Node
Composite:
– Package
1.5. MODELLING ELEMENTS: COMPONENTS 37
1.5.1 Commentary
1.6.1 Commentary
State:
– Transitions
– Events
– Activities
– Rounded rectangle with name
Interaction:
1.7.1 Commentary
Attributes Attributes
Operations Operations
Node Interface
Use Case
Package Note
Component
Can be stereotyped
Stock Option
Using Black-Scholes
TheorPrice()
MarketPrice() Formula
ExpireDate()
44 CHAPTER 1. LECTURE 0: INTRODUCTION TO UML
1.9.1 Commentary
Graphical
Add semantics
Multiplicities of relationships
46 CHAPTER 1. LECTURE 0: INTRODUCTION TO UML
1.10.1 Commentary
1.11 Specification
1.12.1 Commentary
<<become>>
<<constructor>>
<<copy>>
<<enumeration>>
<<exceptions>>
<<friend>>
<<helper>>
<<includes>>
<<process>>
<<send>>
<<query>>
<<type>>
50 CHAPTER 1. LECTURE 0: INTRODUCTION TO UML
1.13.1 Commentary
{version=...}
{abstract}
{author=...}
{status=...}
52 CHAPTER 1. LECTURE 0: INTRODUCTION TO UML
1.14.1 Commentary
{disjoint}
{subset}
{overlapping}
{constraint1, constrraint2}
54 CHAPTER 1. LECTURE 0: INTRODUCTION TO UML
1.15 Diagrams
Use-case
Class
Object
State
Sequence
Collaboration
Activity
Package
Component
Deployment
1.15. DIAGRAMS 55
1.15.1 Commentary
1.16.1 Commentary
<<Boundary>>
name (b)
attributes
operations
(a) (c)
1.17. CLASS DIAGRAM 59
1.17.1 Commentary
arrived
arrived
Moving to first
floor
go down
time-out
1.18. STATE DIAGRAM 61
1.18.1 Commentary
Registrar
1: Print (file)
2: Print(file)
1.19.1 Commentary
:Computer :PrinterQueue
1.20.1 Commentary
Show
[disk Full] MessageBox
PrintFile() "Disk full"
on screen
Show
[free disk space] MessageBox
"Printing"
on screen
1.21.1 Commentary
Interfaces UniversityArtifacts
People
1.23. COMPONENT DIAGRAM 69
Item.java Loan.java
BorrowerInformation.java
Title.java Reservation.java
70 CHAPTER 1. LECTURE 0: INTRODUCTION TO UML
Dorm
Registration
DatabaseServer
lecturer.exe student.exe
Library
Main Building
student.exe
student.exe
1.25. VIEWS 71
1.25 Views
Design View
(Logical) Implementation View
structure (Component)
behaviour system assembly
configuration
manage,ment
Use-Case View
functionalities
system services
actors
Process View
(Concurrency) Deployment View
threads system topology
processes distribution
performance delivery
scaling installation
throughput
1.26. UML VIEWS 73
1.26.1 Commentary
Designers, developers
Interfaces
Nonfunctional
– Parallel execution
– Threads handling (communication & synchronisa-
tion)
Running
Forward Backward
Deployment diagram
1.37 Commentary
http://www.rational.com/ http://www.rational.com/products/rose/tryit/stu
Argo/UML (FREE):
http://www.ics.uci.edu/pub/arch/uml/
(a) Dependency;
(b) Association with multiplicity and role names;
(c) Generalisation;
(d) Realisation.
89
90 CHAPTER 2. LECTURE 1: USE CASES AND USE CASE DIAGRAMS
Introduction
Actor
Use Case
2.2 Commentary
2.3 Introduction
2.4 Commentary
2.5 Actor
2.6 Commentary
Student
<<actor>>
Student
stereotyped
class
equivalent
Student to the icon
2.8. ACTOR INTERACTIONS WITH A SYSTEM 97
Interface
Person
Lecturer Student
2.10. EXAMPLE: ACTORS IN A UNIVERSITY COURSE REGISTRATION SYS. 99
Student
Lecturer
Registrar
Billing System
University
Course
Registration
System
Registrar Student
<<include>>
<<include>>Signing Insurance
Stereotyped Relationship
106 CHAPTER 2. LECTURE 1: USE CASES AND USE CASE DIAGRAMS
<<Communicates>>
Salesman
Price Deal
<<include>>
Valuation
2.17. << EXTEND >> RELATIONSHIP 107
2.18 Commentary
Sales Statistics
Salesperson
Customer
Customer Statitics
2.21. EXAMPLE: UNIVERSITY COURSE REGISTRATION 111
Determine Actors:
– Names
– Documentations (brief descriptions – iterative)
– Names
– Documentations (brief descriptions, and also docu-
mentation of the flow of events – iterative)
Actor names:
– Student
– Lecturer
– Registrar
– Billing System
2.23 Actors
Student Lecturer
Name; student Name: Lecturer
Documentation: a person registered Documentation: a person
to take classes at the University certified to teach at the
University
etc.
116 CHAPTER 2. LECTURE 1: USE CASES AND USE CASE DIAGRAMS
....
118 CHAPTER 2. LECTURE 1: USE CASES AND USE CASE DIAGRAMS
....
– Preconditions:
– Main Flow:
If the activity selected is ADD, then S-1: Add a
Course Offering sub-flow is performed.
...
– Sub-flows:
S-1: Add a Course Offering ...
S-2: ...
– Alternative Flows:
E-1: An invalid lecturer ID number is entered.
The user can re-enter a lecturer id number or ter-
minate the use case.
E-2: ...
– ....
2.29. USE CASE RELATIONSHIPS 119
Communication Association:
– Include or extend
– Stick arrow head is put nearest to the use case that
is being used
– Stick arrow head is put next to the base use case
that is being extended.
– Include and extend are stereotype associations be-
tween use cases
120 CHAPTER 2. LECTURE 1: USE CASES AND USE CASE DIAGRAMS
<<extend>>
<<Communicates>>
<<include>>
2.31. USE CASE DIAGRAMS IN COURSE REGISTRATION SYSTEM 121
Main
Lecturer
Request Course Roster
<<include>> <<include>>
Validate User
124 CHAPTER 2. LECTURE 1: USE CASES AND USE CASE DIAGRAMS
2.36 Commentary
2.37 Scenario
<<realizes>>
<<implements>>
<<implements>>
<<implements>>
<<boundary>> <<control>> <<entity>>
Class A Class B Class C
Use case description
1. Actor Pushes button
2. Use case does action Oper1() Oper1() Oper1()
3. Use case responds to Oper2() Oper2() Oper2()
......
actor with message Oper3() Oper3() Oper3()
4. ... ..... ..... .....
2.39. USE CASE, COLLABORATION, SCENARIO 129
Sequence
diagram
inside the Description
Collaboration Collaboration
system of an
(context and diagram
boundary interaction
interaction)
Activity
diagram
is an instance of a
May be illustrated
by one or more
is an instance of a
Sequence
diagram
Description
Collaboration
of a
An execution diagram
scenario
path through Scenario
Activity
the system diagram
130 CHAPTER 2. LECTURE 1: USE CASES AND USE CASE DIAGRAMS
Credit.
133
134CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Classes
Relationships
Class Diagrams
Interfaces
Instances
Objects
Object Diagrams
Packages
Package Diagrams
Inheritance
3.1. STATIC MODELLING: CLASSES, OBJECTS, PACKAGES, DIAGRAMS 135
3.1.1 Commentary
3.2 Classes
– Name
– attributes
– operations (behaviour)
– responsibilities (documenting specification)
Stereotypes
Templates
– LecturerCourseOptions
– AddACourseOffering
– Course
– CourseOffering
– LecturerCourseManager
– LecturerInformation
– StudentInformation
3.3. COMMENTARY: CLASS 137
Operation syntax:
– courseName
– courseDescription
– creditHours
– getOffering()
– addLecturer()
– validLecturer(lecturerID)
Course
courseName
courseDescription
creditHours
getOffering()
addLecturer()
validLecturer(lecturerID)
3.10. COMMENTARY 145
3.10 Commentary
– getOffering() in CourseOffering
– getOffering(Course) in LecturerCourseManager, Course
– setLecturer(LecturerInformation, CourseOffering) in
LecturerCourseManager
– addLecturer(LecturerInformation, CourseOffering) in
Course
– addLecturer(LecturerInformation) in CourseOffering
– validateLecturer(LecturerInformation) in Course
3.12 Commentary
Car Class
Car
Car registrationNumber
data
speed
direction
Car Car
registrationNumber: String + registrationNumber: String
data: CarData - data: CarData
speed: Integer + speed: Integer
direction: Direction + direction: Direction
Car
+ registrationNumber: String
- data: CarData
+ speed: Integer
+ direction: Direction
+ drive(speed: Integer, direction: Direction)
+ getData(): CarData
150CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Invoice
+ amount: Real
+ date: Date = currentDate
+ customer: String
+ specification: String
- administrator: String = "Unspecified"
-number of invoices: Integer
+ status: Status = unpaid{unpaid, paid}
3.16. COMMENTARY 151
3.16 Commentary
Attribute Documentation:
Operation Documentation:
Student Information
Documentation:
Information needed to
register and bill students.
A student is some one who
is registered to take classes
at the University
154CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
<<Entity>> <<Entity>>
LecturerInformation
CourseOffering
(from People) (from UniversityArtifacts)
<<Boundary>> <<Control>>
LecturerCourseOptions LecturerCourseManager
(from Interfaces) (from UniversityArtifacts)
<<Entity>>
Student Information
Specification:
Name: StudentInformation
Type: class
Stereotype: Entity
Array<Car,100>
T, n:Integer
Array
<<bind>> <Colour,50>
ColourArray
3.22. COMMENTARY 157
3.22 Commentary
Association
Dependency
Specialisation, Generalisation
Packaging
Refinement, Realisation
3.24. COMMENTARY 159
3.24 Commentary
3.25 Association
Association
Navigable Association
Aggregation
LecturerCourseManager Course
3.26. COMMENTARY 161
3.26 Commentary
– meaning
– association name
– role name
Example:
3.28 Commentary
Exactly 1: 1
Example:
Person Car
1..* Owns 0..*
Owned by
3.30. COMMENTARY 165
3.30 Commentary
Default multiplicity is 1.
166CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
LecturerInformation CourseOffering
Teacher
Information (from UniversityArtifacts)
3.32. COMMENTARY 167
3.32 Commentary
Owns 0..*
Person Car
3.35 Aggregation
Course CourseOffering
3.36. COMMENTARY 171
3.36 Commentary
0..*
Team 0..*
Person
Members
3.38. COMPOSITION AGGREGATION 173
3.39 Commentary
0..*
Text
0..*
LicstBox
Window
Button
0..*
Menu
0..*
176CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
0..*
Text
0..*
ListBox
Window
0..*
Button
0..* Menu
3.42. COMPOSITION AGGREGATION: PARTS INSIDE WHOLE CLASS 177
Window
*
Text
*
LicstBox
*
Button
*
Menu
178CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
A
B
B:X X
C
C:X
A
0..
z[0..]:Z z Z
3.44. QUALIFIED ASSOCIATION 179
0..*
Canvas figure id Figure
180CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.45 Commentary
3.46 Or-Association
Insurance Insurance
Company 1 0..* Contract
0..* 0..*
or
1..* 1..*
Person Company
182CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.47 Commentary
Labelled: {ordered}
3.49 Commentary
*
Node
*
186CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.51 Commentary
* means 0 or more.
3.52. RECURSIVE ASSOCIATION 187
Node4
Node5
Node7
Node6 Node8
188CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.53 Commentary
Multiplicity at LecturerCourseManager: 1
Multiplicity at Course: 1
0..*
190CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.55 Commentary
Example:
1..* 0..1
Person Company
employer
Employment
period: dateRange
Association Class
192CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.57 Commentary
Diamond
Insurance Policy
0..1
1..* policyHolder
Person
194CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.59 Commentary
class relationships
3.61 Commentary
Insurance
company 1 0..* Insurance
contract
0..*
1..*
Customer
198CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.63 Commentary
:Order
2 *[for all order lines]:prepare()
3:hasStock()=check() 5:needsReorder:=
4 [hasStock]:remove() needToReorder()
:Order Line :Stock Item
7[hasStock]:new 6 [needsReorder]:new
3.65 Commentary
Order Customer
dateReceived name
isPrepaid 0..* 1
address
number: String
price: Money
dispatch() creditRating(): String
close()
1 {if Order.customer.creditRatring
is "poor", then Order: isPrepaid
must be true}
line
items 0..* Personal
Corporate Customer
Customer
OrderLine contactName
creditCard#
creditRating
quantity: Integer
creditLimit remind
price: Money
isSatisfied: Boolean billForMonth(Integer)
0..*
sales rep 0..1 {creditRating() = "poor"}
0..*
Employee
1
Product
.
202CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
object instances
p1/lead: Point
x = 3.14
y = 2.718
lead: Point
roles objects
204CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.68.1 Commentary
Author Computer
Use
name: String
name: String
age: Integer memory: Integer
0..* 1..*
3.69.1 Commentary
3.70 Interfaces
Storable
Class A Class B
Runnable
<<interface>>
Runnable
{abstract}
Runnable
run(){abstract}
<<interface>>
Storable Class C
{abstract}
load(){abstract}
save(){abstract}
Class A supplies (realises) interfaces Storable & Runnable
Class C supplies (realises) interface Runnable
Class B uses (depends on) Storable & Runnable interfaces
provided by Classes A & C
208CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.70.1 Commentary
Interfaces UniversityArtifacts
People
No instantiation; no aggregation/association
Visibility of components
210CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.72 Commentary
Package Interfaces:
– LecturerCourseOptions
– AddACourseOffering
Package UniversityArtifacts:
– Course
– CourseOffering
– LecturerCourseManager
Package People:
– LecturerInformation
– StudentInformation
214CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Course CourseOffering
(from UniversityArtifacts) (from UniversityArtifacts)
LecturerCourseManager
(from UniversityArtifacts)
3.75. EXAMPLE PACKAGES: CLASS DEPENDENCE ON PACKAGE INTERFACE 215
Class P Class S
B
D
C
216CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Dependency relationship
Dashed line
Interfaces UniversityArtifacts
3.77. COMMENTARY 217
3.77 Commentary
SubSystemA
SubSystemB SubSystemC
SubSystemE
SubSystemD
3.79. EXAMPLE PACKAGES: SUBSYSTEM IMPORTING 219
B W::Z
220CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
SubSystemA
SubSystemB SubSystemC
SubSystemD SubSystemE
3.81. GENERALISATION (INHERITANCE) RELATIONSHIPS 221
Parent: UserInformation
Child1: LecturerInformation
Child2: StudentInformation
UserInformation
LecturerInformation StudentInformation
222CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.82 Commentary
Parent: Vehicle
Child1: Car
Child2: Boat
Child3: Truck
Vehicle
Vehicle
Vehicle
Car Boat
Vehicle {abstract}
drive() {abstract}
Car Boat
drive() drive()
3.87 Commentary
*
Vehicle {abstract}
drives colour
Person
drive() {abstract}
Car Boat
drive()
drive()
Parent: UserInformation
Child1: LecturerInformation
– Attributes:
tenureStatus
name
IDNumber
– Association:
Association: to CourseOffering
Multiplicity at LecturerInformation: 1
Multiplicity at CourseOffering: 0..4
Role at LecturerInformation: Teacher Information
Child2: StudentInformation
– Attributes:
major
name
IDNumber
– Association: to CourseOffering
Multiplicity at StudentInformation: 3..10
Multiplicity at CourseOffering: 0..4
3.90. INHERITANCE RELATIONSHIP WITH CLASS ATTRIBS. AND ASSOCS. 231
UserInformation
1 3..10
Teacher
Information
0..4 0..4
CourseOffering
232CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Parent: UserInformation
– Attributes:
name
IDNumber
Child1: LecturerInformation
– Attributes:
tenureStatus
– Association:
Association: to CourseOffering
Multiplicity at LecturerInformation: 1
Multiplicity at CourseOffering: 0..4
Role at LecturerInformation: Teacher Information
Child2: StudentInformation
– Attributes:
major
– Association: to CourseOffering
Multiplicity at StudentInformation: 3..10
Multiplicity at CourseOffering: 0..4
3.92. INHERITANCE RELATIONSHIP WITH REALLOCATED ATTRIBS. AND OPS. 233
UserInformation
name
IDNumber
LecturerInformation StudentInformation
tenureStatus major
1 3..10
Teacher
Information
0..4 0..4
CourseOffering
234CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Example:
– Parent: UserInformation
Attributes:
name
IDNumber
– Child1: LecturerInformation
Attributes:
tenureStatus
– Child2: StudentInformation
Attributes:
major
Aggregation: to Classification
Multiplicity at StudentInformation: 0..*
Multiplicity at Classification: 1
3.94. EXAMPLE: INHERITANCE VS AGGREGATE CONTD. 235
Classification hierarchy:
– Parent: Classification
Attributes:
maxCourseLoad
– Child1: Fulltime
Attributes:
gradYear
– Child2: Parttime
Attributes:
yearsInAttendance
236CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
UserInformation
name
IDNumber
Lecturer Student
Information Classification
Information
tenureStatus maxCourseLoad
1
major 0..*
Fulltime Parttime
gradYear yearsInAttendance
3.96. CONSTRAINT GENERALISATIONS: INHERITANCE CONSTRAINTS 237
complete,
disjoint,
incomplete,
overlapping.
Class A
Class A
Vehicle
Propulsion Propulsion
{overlapping}
Car Boat
Amphibian
NOT Java
Vehicle
Four-wheeled Two-wheeled
{disjoint}
Car Mototor-Cycle
Default
3.100. COMPLETE GENERALISATION: NO OTHER SUB-CLASS 241
Person
{complete}
Man Woman
<<friend>>
Class A Class B
Parameter class
Refinement ) Realisation
Type Class
B A
B modifies to A
A does what B promises
B (input), A (result)
A refinement of B (A refines B)
244CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.103 Commentary
Receipt
0..1
is expressed in
1
Car Hire has Hire refers to Rental Car
Company 1 0..*Contract {abstract}
0..1
0..* {disjoint}
Kind of car
signs
1
3.105 Commentary
Member of 1
1..*
Politician {subset} Party
1
Party leader of 1
Or-association
f orderedg
3.107 Commentary
Invoice
+amount: Real
+date: Date = Current date
+customer: String
+specification: String
-administrator: String = "Unspecified"
-number of invoices: Integer
+status: Status = unpaid{unpaid, paid}
250CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.109 Commentary
Article
costPrice
salesPrice
/profit
3.111 Commentary
name: Figure,
attributes: size of class Size, pos of class Position,
figCounter of type Integer and of class scope, x
and y both of Integer type and of default value 0
with private visibility,
operations: draw() with public visibility, getCounter()
returning Integer value and of class scope, scaleFigure
of public visibility and with an Integer parameter percent
defaulted to 25, reSize of public visibility and with
2 Integer parameters percentX and percentY both
defaulted to 25, returnPos() of class Position
and of public visibility,
254CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
<<Boundary>>
name (b)
attributes
operations
(a) (c)
10. For the Motor Race Information System draw the main
Class diagrams giving appropriate class attributes, op-
erations and specifications and making appropriate use
3.112. LECTURE 2 EXERCISES: 257
Sequence Diagrams
Collaboration Diagrams
Activity Diagrams
State Diagrams
260CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.114 Commentary
:Computer :Queue
:Printer- :Printer
Server
Registrar
1: Print (file)
anonymous
2: Print(file) object
condition
life line
GENERIC
Message Numbering Optional
Activation Return
Return Message Not Always shown
Synchronous Messages
266CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Timing constraint:
Message must be sent within the time interval
e.g., Print Server must respond within 5 secs.
3.119. EXAMPLE: USE OF LABEL FOR ITERATION 267
Registrar
op1()
{send op2()
message
op2 op3()
until...}
oper() objectName:Class
oper()
recursion
activation
Activation
self
delegation
Registrar
object
name &
1:set Course type
info
2:process
3:add course
4:new course
3:enter term
4:addAOffering5:display
6:select cs223 7:getOfferings
8:getOfferings
9:getOfferings
10:displayOfferings
11:selectOffering
12:setOffering
13:addLecturer
14:addLecturer
self delegation
3.123. EXAMPLE: ORDER SEQUENCE 271
<<create>> object
iteration [needsReorder] creation
new() a reorderitem
<<create>>
[hasStock]new() a deliveryitem
return
new
new
a Transaction
object
new a Transaction creation
Coordinator
<<create>>
new a first
<<create>> transaction
checker
a second
new transaction
<<create>>
checker
stop & ok
<<destroy>>
resume
all
activation done?
ok
<<destroy>>
all
be valid done?
object destruction
asynchronous
3.125. EXAMPLE: TRANSACTION CHECK 273
transaction
created
new
new
a Transaction
<<create>>
transaction new a Transaction
coordinator Coordinator
created <<create>>
new a first
Coordinator transaction
creates first <<create>>
checker
checker a second
Coordinator new transaction
<<create>>
creates second checker
checker fail
first checker <<destroy>>
fails checkers
all checkers
killed <<destroy>>
Transaction be invalid
informed
of invalid
checks
Optional Comments
274CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.126 Commentary
3.128 Commentary
Predecessor is specified as :
Guard-condition:
’[’ condition-clause ’]’
e.g.: [mode = evaluate]
Sequence-expression:
[integer | name] [recurrence] ’:’
e.g.: 2 *[n := 1..z]:
[integer | name]
e.g.: 1.2.3.7:
1.1a, 1.1b/1.2:
[recurrence]
conditional: ’[’ condition-clause ’]’
e.g.: [x<0]
iteration: ’*’ ’[’ iteration-clause ’]’
e.g.: *[x=1..10] (
Return-value := Signature:
return-value := signature
eg.g.: x := calc(n)
prim := nextPrim(prim)
3.131. LINKS 279
3.131 Links
Instance of Association
280CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Registrar
object
1: Print(file)
message
:PrinterServer
sequence no.
[printer free]
2:Print(file)
condition
:Printer
calcPrime(n) :Calculator
1*[z:=1..n]:prime:=nextPrime(prime)
iterator
:Prime module
push() :Button
1:getElevator(floorid)
:elevator
:order {new} 1.2: <<create>>
control
job
2:nextjob=GetJob() :Queue
:Elevator
1:show()
:Sales Statistics
Window
:Statistics :order
Summary
{new} 1.1.1.1 *[for all orders]:
GetOrderAmount()
1.1.1 *[for all salespersons]:
ordersum=GetTotalOrderSum()
:SalesPerson
1.1.2 *[for all salespersons]:
budget=GetBudget()
1.1.2.1:GetBudgetAmount()
:Budget Sales
286CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
1. show() SalesStatisticsWindow
1: new student
sof:StudentOptionsForm
sf:StudentForm
4: new student
5: save
successFlag
s:Student
288CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
2. display StudentForm
1: add a course
cof:CourseOfferingForm
cf: CourseForm
co: CourseOffering
290CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
2. display CourseForm
Registrat
3:addCourse
cm:CurriculumMananger
4:newCourse
c:Course
292CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
2. process CourseForm
:Order
2 *[for all order lines]:prepare()
3:hasStock()=check() 5:needsReorder:=
4 [hasStock]:remove() needToReorder()
:Order Line :Stock Item
7[hasStock]:new 6 [needsReorder]:new
6. if so reorder
7. deliver item
3.147. ACTIVITY DIAGRAMS 295
Interaction diagram
296CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.148 Commentary
3.149 Transitions
3.150 Commentary
Sampler.Run(channel, frequency)
Initiate
(fork)
(join)
must combine before exiting
300CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.152 Commentary
Displayer Sampler
Sampler.Run(channel, frequency)
Initiate
Measuring
Updating
displayer
swim lanes
302CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.154 Commentary
Swim lanes show action states of the same object. All the
activities in the same swim lane refer to the same object.
3.155. ACTIVITY DIAGRAM: USING OBJECTS WITH ACTIVITY DIAGRAM 303
Displayer Sampler
Sampler.Run(channel, frequency)
Initiate
Updating Measured
Measuring
displayer value
Object
Object sent to Updating displayer action by Measuring action
304CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.156 Commentary
Create
postscript Print
file
Print(file) Print(file)
Print Signal
Remove
Message Box
3.158 Commentary
Receive
Order
multiple
trigger
Receive
Supply
Choosing
Outstanding multiple trigger
Order Items
*[for each chosen order]
Assign
Goods to
Order
[stock assigned
to all line items and [all outstanding
payment authorized] order items filled]
Dispatch Add
Order Remainder
to Stock
3.161. ACTIVITY DIAGRAM: SWIM LANE FOR ORDER PROCESSING 309
Dispatch Add
Remainder
Order
to Stock
Process receieved order and received reordered stock
310CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
[cheque] [invoice]
failed
[failed] Clear Regular Value
[no] [yes]
Cheque Customer? of Order
>$1,000?
[OK] [yes]
[failed] [no]
Request
Authorize Check [failed] Pre- [not receivd]
Credit Payment Payment
Card history
failed
[OK] [failed]
Credit
[OK]
Check
Open
Customer
[OK]
succeeded Account
Complex method using activity diagram (algorithm flow chart!)
3.163. COMMENTARY 311
3.163 Commentary
3.164 State
Name
State Variable
Activities:
Name
State Variables
Activities
3.165 Commentary
Login
Login time=currentTime
entry/type "login"
exit/login(userName, password)
do/get userName
do/get password
help/display help
3.167 Commentary
Boot Starting OS
triggerless transition
Starting Application
do/load applications
3.169. TRANSITIONS 317
3.169 Transitions
3.170 Commentary
Stop (optional)
322CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Paid
invoice
destroying
3.174. EXAMPLE STATES: COURSEOFFERING 323
Cancelled
Guard Condition:
3.176 Commentary
send CourseReport.createReport()
[timer=Time-out] send self.goDown(firstfloor)
out-of-paper() send indicator.light()
leftMouseButtonDown(location)/color:=
pickColor(location) send pen.set(color)
326CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Initialisation
do:Initialise
CourseOffering data
add student/set count = 0
add student [Count < 10]
Open
Cancelled Closed
cancel course do: Finalise course
do: send exit: send
cancellation notices
Course Report.
Create Report
<<send>>
CourseReport.delete
328CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Remote Control
on()
Off On
off()
play() stop()
CD Player
on() play()
Off On/Play
On/Stop
off() stop()
off()/stop()
330CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.181 Commentary
<<signal>> <<signal>>
Left Mouse Button Right Mouse Button
signal hierarchy
332CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.183 Or State
Running
Forward Backward
3.184. AND STATE 333
Running
Forward Backward
Install
OS running restart()
create()
Restart OS
send Self.Restart()
Install
Start Install shield
entry/ask installing
questions
H
do/Install software
[alternative=try again]
[alternative=continue]
out of memory()
disc error()
Memory Error
Disk Error
entry/fix disk entry/show question dialog
do/show question dialog
do/ask alternative
dp/ask alternative
[alternative=stop]
Internal state is remembered by History state and is
returned to when resumed after interruption
3.186. ORDER PROCESSING 335
Delivered
Delivered Waiting
Cancelled cancel
Delivered Waiting
Items Received
[Some items not Waiting
in stock]
Delivered
cancel
Delivered Cancelled
338CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Authorising
do/check
[payment not OK]
payment
[payment OK]
Authorised Rejected
Delivered
3.190. CONCURRENT STATES IN ORDER PROCESSING 339
canelled
Waiting
Cancelled
Checking Dispatching
Delivered
Authorising Authorised
Rejected
340CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
the line) and delta (giving the offset of the line relative
to the origin). Give the corresponding Java implemen-
tation for intersection().
[slope=l.slope]
return
Point(0,0)
else
x=(l.delta-delta)/(slope-l.slope);
y=(slope*x)+delta;
return
Point(x,y)
go up (floor) Moving up
On first floor
do/moving to floor
arrived
go up (floor)
Idle
Moving down timer=0
arrived
do/moving to floor
do/increase timer
go down (floor)
10. For the Motor Race Information System draw the rel-
344CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Architectural Views
Logical Views
Components
Processes
Deployment
Collaborations
Design View
(Logical) Implementation View
structure (Component)
behaviour system assembly
configuration
manage,ment
Use-Case View
functionalities
system services
actors
Process View
(Concurrency) Deployment View
threads system topology
processes distribution
performance delivery
scaling installation
throughput
348CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
– implementation language
– database
– GUI
– error handling
– communication mechanism
– object distribution & migration
– networking
3.195. LOGICAL VIEW OF PACKAGE IN COURSE REGISTRATION 349
Interfaces
University Artifacts
GUI Controls
People
Databases
GUI Controls
Database
ErrorHandling Foundations
3.197. COMPONENT VIEW & DIAGRAMS 351
Packages of components;
Example Components:
Agent.java FraudAgent.dll
Realizes
FraudAgent
FraudPolicy
PatternSearch
System::dialog.dll
{version=2.0.1.75}
3.199. COMPONENT AND CLASSES 353
FraudAgent.dll
Classes
Army.java SecretAgent.java
Decoder
realization
dependency
Army.java SecretAgent.java
<<interface>>
Decoder
breakCode()
3.201. COMPONENTS AND INTERFACES CONT’D. 355
3 kinds of components:
Interfaces
University Artifacts
Databases
Foundations
Error Handling
Foundations Databases
3.205. SOFTWARE COMPONENTS OF UNIVERSITY CLASS 359
Course
CourseOffering
UserInformation
LecturerInformation
StudentInformation
Course CourseOffering
UserInformation
LecturerInformation StudentInformation
360CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Connection types
Component dependencies
Lecturer.exe
Course.dll
Database.dll
LecturerCourseOption
LecturerInformation
AddACourseOffering
LecturerInformation AddACourseOffering
LecturerCourseOption
362CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
Registration (Lecturer.exe)
Database Server
Dorm (student.exe)
Library (student.exe)
lecturer.exe student.exe
Library
Main Building
student.exe
student.exe
3.209. COLLABORATION 363
3.209 Collaboration
Inter-node messaging
364CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
<<framework>>
Design Pattern
Architectural Pattern
Gamma et. al. Buschmann et. al.
"Design Patterns" "A System of Patterns"
(1995) (1996)
3.211. DESIGN PATTERNS 365
Receiver Client
Document Command
Invoker
Client Receiver
Application
Command
Command
PasteCommand
Command
OpenCommand
MenuItem Invoker
366CHAPTER 3. LECTURE 2: CLASSES, OBJECTS, PACKAGES AND CORRESPONDING DIAGRAMS
3.212 Mechanisms
TaskQueue Subject
Subject
Observer
Observer
SliderBar Observer
3.213. ARCHITECTURAL PATTERNS – FRAMEWORKS 367
3.214 Frameworks
...
3.214. FRAMEWORKS 369
<<framework>>
Blackboard
KnowledgeSource
Blackboard
Control
Blackboard
KnowledgeSource
Reasoning Engine