– 6 – 2016-11-15 – main –
Software Design, Modelling and Analysis in UML
Lecture 6: Class Diagrams I
2016-11-15
- Prof. Dr. Andreas Podelski, Dr. Bernd Westphal
Albert-Ludwigs-Universität Freiburg, Germany
Lecture 6: Class Diagrams I 2016-11-15 Prof. Dr. Andreas Podelski, - - PowerPoint PPT Presentation
Software Design, Modelling and Analysis in UML Lecture 6: Class Diagrams I 2016-11-15 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universitt Freiburg, Germany 6 2016-11-15 main Course Map N UML W E CD ,
– 6 – 2016-11-15 – main –
2016-11-15
Albert-Ludwigs-Universität Freiburg, Germany
– 6 – 2016-11-15 – main –
2/31
N S W E
CD, SM S = (T, C, V, atr ), SM M = (ΣD
S , AS , →SM )
ϕ ∈ OCL expr CD, SD S , SD B = (QSD, q0, AS , →SD, FSD) π = (σ0, ε0)
(cons0,Snd0)
− − − − − − − − →
u0
(σ1, ε1)· · · wπ = ((σi, consi, Sndi))i∈N G = (N, E, f)
OD
– 6 – 2016-11-15 – Scontent –
3/31
Extended Signatures
– 6 – 2016-11-15 – main –
4/31
– 6 – 2016-11-15 – Sstock –
5/31
– 2 – 2016-10-20 – Ssemdom –
7/20 S = (T, C, V, atr ) where
Example:
– 6 – 2016-11-15 – Sstock –
6/31
+ r : Package::C0,1 = expr s : D∗ {ordered} − v : Int = 27 w : Float {readOnly}
A
y : Int
B
{A}
D
x : Int
– 6 – 2016-11-15 – Sstock –
7/31
A class
+ r : Package::C0,1 = expr s : D∗ {ordered} − v : Int = 27 w : Float {readOnly}
A
y : Int
B
{A}
D
x : Int
Each attribute has
Wanted: places in the signature to represent the information from the picture.
– 6 – 2016-11-15 – main –
8/31
– 6 – 2016-11-15 – Sextsig –
9/31
S = (T, C, V, atr ) where
:=+
, private
:=−
, protected
, package
} is the visibility,
expressions, e.g. OCL, or C++ in the Rhapsody tool; write ‘⊲ ⊳’ to explicitly not give an initial value expression.
We use SC to denote the set
C∈C SC of stereotypes in S .
– 6 – 2016-11-15 – Sextsig –
10/31
S = (T, C, V, atr ), C, SC, a, t ∈ C , v : T, ξ, expr 0, Pv ∈ V S =
{Package::C, {Stereotype1, . . . , Stereotypen}, 0, 0, A, ∅, 1, 0, B, ∅, 1, 0, D, ∅, 0, 1}, {r : Package::C0,1, +, expr, ∅, s : D∗, +, ⊲ ⊳, {ordered}, v : Int, −, 27, ∅, w : Float, +, ⊲ ⊳, {readOnly}, x : Int, +, ⊲ ⊳, ∅, y : Int, +, ⊲ ⊳, ∅}, {Package::C → {r, s, v, w}, A → {y}, B → ∅, D → {x}}
– 6 – 2016-11-15 – Sextsig –
11/31
we simply write C i.e. old definitions (written in terms of C) are still valid.
– 6 – 2016-11-15 – Sextsig –
12/31
Recall:
S = (T, C, V, atr ) is a domain function D which assigns to each type a domain, i.e.
Note: Object identities only have the “=" operation.
∀ C, D ∈ C : C = D → D(C) ∩ D(D) = ∅.
We use D(C ) to denote
C∈C D(C); analogously D(C∗).
– 6 – 2016-11-15 – Sextsig –
12/31
New:
nature S = (T, C, V, atr ) is a domain function D which assigns to each type a domain, i.e.
Note: Object identities only have the “=" operation.
∀ C, D ∈ C : C = D → D(C) ∩ D(D) = ∅.
We use D(C ) to denote
C∈C D(C); analogously D(C∗).
– 6 – 2016-11-15 – Sextsig –
13/31
Recall:
A system state of S wrt. D is a type-consistent mapping σ : D(C ) (V (D(T ) ∪ D(C∗))). That is, for each u ∈ D(C), C ∈ C , if u ∈ dom(σ)
We call u ∈ D(C ) alive in σ if and only if u ∈ dom(σ). We use ΣD
S to denote the set of all system states of S wrt.D.
– 6 – 2016-11-15 – Sextsig –
13/31
New:
A system state of S wrt. D is a type-consistent mapping σ : D(C ) (V (D(T ) ∪ D(C∗))). That is, for each u ∈ D(C), C ∈ C , if u ∈ dom(σ)
We call u ∈ D(C ) alive in σ if and only if u ∈ dom(σ). We use ΣD
S to denote the set of all system states of S wrt.D.
– 6 – 2016-11-15 – Sextsig –
14/31
S .
is the set of sets of system states wrt. some structure of S , i.e. the set {ΣD
S | D is structure of S }.
Which of the following aspects is semantically relevant, i.e. does contribute to the constitution of system states? A class
Each attribute has
such as readOnly, ordered, etc.
– 6 – 2016-11-15 – main –
15/31
– 6 – 2016-11-15 – Scdmap –
16/31
A class box n induces an (extended) signature class as follows: n:
ξ1 v1 : T1 = expr 1
0 {P1,1, . . . , P1,m1}
. . . ξℓ vℓ : Tℓ = expr ℓ
0 {Pℓ,1, . . . , Pℓ,mℓ}
V (n) := {v1 : T1, ξ1, expr 1
0, {P1,1, . . . , P1,m1}, . . . , vℓ : Tℓ, ξℓ, expr ℓ 0, {Pℓ,1, . . . , Pℓ,mℓ}}
atr(n) := {C → {v1, . . . , vℓ}} where
a(n) =
, if n = C
C {A} false , otherwise
t(n) =
, if n = C
C false , otherwise
– 6 – 2016-11-15 – Scdmap –
17/31
ξ1 v1 : T1 = expr 1
0 {P1,1, . . . , P1,m1}
. . . ξℓ vℓ : Tℓ = expr ℓ
0 {Pℓ,1, . . . , Pℓ,mℓ}
V (n) := {v1 : T1, ξ1, expr 1
0, {P1,1, . . . , P1,m1}, . . . ,
vℓ : Tℓ, ξℓ, expr ℓ
0, {Pℓ,1, . . . , Pℓ,mℓ}}
atr(n) := {C → {v1, . . . , vℓ}}
+ r : Package::C0,1 = expr s : D∗ {ordered} − v : Int = 27 w : Float {readOnly}
A
y : Int
B
{A}
D
x : Int
– 6 – 2016-11-15 – Scdmap –
18/31
It depends.
“Presentation Options. The type, visibility, default, multiplicity, property string may be suppressed from being displayed, even if there are values in the model.”
Some (and we) assume public as default, but conventions may vary.
“leftmost” of Z?). Some (and we) understand non-deterministic initialisation if not given.
– 6 – 2016-11-15 – Scdmap –
19/31
ξ1 v1 : T1 = expr 1
0 {P1,1, . . . , P1,m1}
. . . ξℓ vℓ : Tℓ = expr ℓ
0 {Pℓ,1, . . . , Pℓ,mℓ}
V (n) := {v1 : T1, ξ1, expr 1
0, {P1,1, . . . , P1,m1}, . . . ,
vℓ : Tℓ, ξℓ, expr ℓ
0, {Pℓ,1, . . . , Pℓ,mℓ}}
atr(n) := {C → {v1, . . . , vℓ}}
+ r : Package::C0,1 = expr s : D∗ {ordered} − v : Int = 27 w : Float {readOnly}
A
y : Int
B
{A}
D
x : Int
S = {Int, Float}, {Package::C, {Stereotype1, . . . , Stereotypen}, 0, 0, A, ∅, 1, 0, B, ∅, 1, 0, D, ∅, 0, 1}, {r : Package::C0,1, +, expr, ∅, s : D∗, +, ⊲ ⊳, {ordered}, v : Int, −, 27, ∅, w : Float, +, ⊲ ⊳, {readOnly}, x : Int, +, ⊲ ⊳, ∅, y : Int, +, ⊲ ⊳, ∅}, {Package::C → {r, s, v, w}, A → {y}, B → ∅, D → {x}}
– 6 – 2016-11-15 – Scdmap –
20/31
(each “class rectangle” is a node).
i=1 V (ni)
i=1 atr(ni)
C D = {CD1, . . . , CDk}, which induce the following signature: S (C D) =
k
C (CDi),
k
V (CDi),
k
atr(CDi)
(Assuming T given. In “reality” (i.e. in full UML), we can introduce types in class diagrams, the class diagram then contributes to T . Example: enumeration types.)
– 6 – 2016-11-15 – Scdmap –
21/31
Question: Is S (C D) well-defined? There are two possible sources for problems: (1) A class C may appear in multiple class diagrams: (i)
C
v : Int = 0 CD1
C
w : Int = 27 CD2 (ii)
C
v : Int = 0 CD1
C
v : Int = 27 CD2 Simply forbid the case (ii) — easy syntactical check on diagram.
– 6 – 2016-11-15 – Scdmap –
22/31
(2) An attribute v may appear in multiple classes with different type:
C
v : Bool
D
v : Int Two approaches:
This requirement can easily be established (implicitly, behind the scenes) by viewing v as an abbreviation for C::v
D::v depending on the context. (C::v : Bool and D::v : Int are then unique.)
v : Bool, . . . and v : Int, . . . are different things in V .
– 6 – 2016-11-15 – Scdmap –
23/31
Since we have not yet discussed associations, for now we read
D
r
0, 1
as
C
r : D0,1
D
D
r
∗
as
C
r : D∗
D
and
D
r
0, 1
as
C D
r
0, 1
D
r
∗
as
C D
r
∗
– 6 – 2016-11-15 – main –
24/31
N S W E
CD, SM S = (T, C, V, atr ), SM M = (ΣD
S , AS , →SM )
ϕ ∈ OCL expr CD, SD S , SD B = (QSD, q0, AS , →SD, FSD) π = (σ0, ε0)
(cons0,Snd0)
− − − − − − − − →
u0
(σ1, ε1)· · · wπ = ((σi, consi, Sndi))i∈N G = (N, E, f)
OD
– 6 – 2016-11-15 – main –
25/31
– 6 – 2016-11-15 – Sstereo –
26/31
View stereotypes as (additional) “labelling” (“tags”) or as “grouping”.
Sometimes, packages (cf. OMG (2011a,b)) are sufficient and “right”.
– 6 – 2016-11-15 – Sstereo –
27/31
Core View Application/Qt
Trace
sort move filter jump zoom
View/Qt
Schumann et al. (2008)
Stereotype “=” layer “=” colour.
– 6 – 2016-11-15 – Sstereo –
28/31
for class C.
“submitted for testing”, “accepted”.
Necessary: a common idea of what each stereotype stands for.
(To be defined / agreed on by the team, not the job of the UML consortium.)
– 6 – 2016-11-15 – Sttwytt –
29/31
is that abstract classes cannot have instances.
i.e. the meaning of a class diagram is the extended signature which it uniquely denotes.
(given a structure).
– 6 – 2016-11-15 – main –
30/31
– 6 – 2016-11-15 – main –
31/31 Oestereich, B. (2006). Analyse und Design mit UML 2.1, 8. Auflage. Oldenbourg, 8. edition. OMG (2011a). Unified modeling language: Infrastructure, version 2.4.1. Technical Report formal/2011-08-05. OMG (2011b). Unified modeling language: Superstructure, version 2.4.1. Technical Report formal/2011-08-06. Schumann, M., Steinke, J., Deck, A., and Westphal, B. (2008). Traceviewer technical documentation, version 1.0. Technical report, Carl von Ossietzky Universität Oldenburg und OFFIS.