+ public- private# protected~ package| Attribute Syntax | Description |
|---|---|
+name |
public name |
-name |
private name |
-name:Name |
private name of type Name |
-name:Name = "Project" |
private name of type Name with default "Project" |
-name:Name[3] |
private name of type Name with multiplicity of 3 |
-name:Name = "Project" { persistent } |
private name of type Name with the default "Project", and property 'persistent' |
| Operator Syntax | Description |
|---|---|
+draw() |
public operator draw() |
-draw() |
private operator draw() |
#draw() |
protected operator draw() |
+draw() : Boolean |
public operator draw() with return type Boolean |
+draw() : Boolean {optional} |
public operator draw() with return type Boolean, and a property optional |
| Parameter Syntax | Description |
|---|---|
+draw(: Shape) |
parameter of type Shape |
+draw(s: Shape) |
parameter s of type Shape |
+draw(in shape : Shape) |
in parameter shape of type Shape |
+draw(out picture : Picture) |
out parameter picture of type Picture |
+draw(inout picture : Picture) |
inout parameter picture of type Picture |
Directions: in, out, inout
| C++ Declaration | UML Parameter Direction |
|---|---|
| Shape | in |
| const Shape& | in |
| const Shape* | in |
| Shape& | inout |
| Shape* | inout |
| Shape** | out (typical API usage) |
| Multiplicity Syntax | Description |
|---|---|
* |
Any number of values |
1 |
Single value (default) |
0..1 |
No more than a single value |
2..4 |
Two to four values |
| Multiplicity Term | Description |
|---|---|
| Optional | * |
| Mandatory | 1..* |
| Single-valued | 0..1 |
| Multivalued | 0..2, 0..* |
| Multiplicity | Standard C++ Data Structures |
|---|---|
| Multivalued | std::vector<int>, std::deque<int>, std::list<int>, std::array<int, n> |
| Single-valued | std::optional<int> (C++14) |
| DataType | Class |
|---|---|
| Primitives | Objects |
| Methods are familiar | Methods are not familiar |
| Operators do not change | Operators can change |
| New developers know exactly what you mean | New developers have only a vague idea |
| Tend to be scalar (single value) | Tend to be complex types |
| Equivalent values ⇨ same identity | Two distinct objects can have the same value |
| Probably not a base for generalization (inheritance) | Maybe a base for generalization (inheritance) |
