Reaves.dev

v0.1.0

built using

Phoenix v1.7.12

UML Class Models

Stephen M. Reaves

::

2023-09-12

Notes about Lesson 5 of CS-6310

Summary

Classes

A class is a description of a similar set of instances

Candidates for classes include:

Window
+size: Area
#visibility: Boolean
+default-size: Rectangle
#maximum-size: Rectangle
-foo: List<int>
-xptr: XWindow
+display()
+hide()
+create()
-attachXWindow(xwin: XWindow*)

Name Component

Should be a noun

Italic names means abstract class

Classes can also have stereotypes

Attributes

Instance methods

Generally, it’s of the form [visibility] name: type [= defaultValue]

Visibility modifiers:

Optional multiplicity and ordering

Optional derivation

Operations

[visibility] name([inputs]): [returnType]

Inputs can be of multiple types:

out and inout params roughly translate to parameters passed by reference

Properties:

Advanced Features

Relationships

Verbs

Types of Relationships:

Associations

Solid line between classes

{ordered}
1
3..*
-bundle
1
1
polygon
point
GraphicsBundle
color
texture
density

Polygon Contains Points

Associations can contain

Open diamonds mean aggregation

Closed diamonds mean composition

Navigability is shown by arrows

Numbers, ranges, and * denote multiplicity

“bundle” is a role name in the example

Associations can have constraints

Associations can be recursive

Associations can be qualified

Aggregation and Composition

Aggregations don’t say anything about the lifetimes of the participant objects, composition does

If you destroy a house, you also destroy the rooms, so a house has a composition of rooms, not aggregation

A constituent can only belong to one composition

Composition is transitive, aggregations are not

Links are instances of associations

Association = “Employer hires person”

Link = “IBM hires Bob”

Generalization

Solid line with triangle

Arrow goes on super class

doctor
person

Generalization is not the same as inheritance

Generalization is a modeling technique, inheritance is an implementation technique

power
power
venue
venue
Vehicle
WindPoweredVehicle
MotorPoweredVehicle
LandVehicle
WaterVehicle
Truck
Sailboat