Lecture 6: Class Diagrams I 2015-11-12 Prof. Dr. Andreas Podelski, - - PowerPoint PPT Presentation

lecture 6 class diagrams i
SMART_READER_LITE
LIVE PREVIEW

Lecture 6: Class Diagrams I 2015-11-12 Prof. Dr. Andreas Podelski, - - PowerPoint PPT Presentation

Software Design, Modelling and Analysis in UML Lecture 6: Class Diagrams I 2015-11-12 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal 6 2015-11-12 main Albert-Ludwigs-Universit at Freiburg, Germany Course Map N UML W E CD


slide-1
SLIDE 1

– 6 – 2015-11-12 – main –

Software Design, Modelling and Analysis in UML

Lecture 6: Class Diagrams I

2015-11-12

  • Prof. Dr. Andreas Podelski, Dr. Bernd Westphal

Albert-Ludwigs-Universit¨ at Freiburg, Germany

slide-2
SLIDE 2

Course Map

– 6 – 2015-11-12 – Sprelim –

2/27

UML

Model Instances

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)

Mathematics

OD

UML !

✔ ✔ ✔ ✔ ✔ ✔

slide-3
SLIDE 3

Contents & Goals

– 6 – 2015-11-12 – Sprelim –

3/27

Last Lecture:

  • Object Diagrams
  • partial vs. complete; for analysis; for documentation. . .

This Lecture:

  • Educational Objectives: Capabilities for following tasks/questions.
  • What is a class diagram?
  • For what purposes are class diagrams useful?
  • Could you please map this class diagram to a signature?
  • Could you please map this signature to a class diagram?
  • Content:
  • Study UML syntax.
  • Prepare (extend) definition of signature.
  • Map class diagram to (extended) signature.
  • Stereotypes.
slide-4
SLIDE 4

UML Class Diagrams: Stocktaking

– 6 – 2015-11-12 – main –

4/27

slide-5
SLIDE 5

Recall: Signature vs. Class Diagram

– 6 – 2015-11-12 – Sstock –

5/27

Basic Object System Signature Another Example

– 2 – 2015-10-22 – Ssemdom –

7/34 S = (T, C, V, atr ) where

  • (basic) types T and classes C (both finite),
  • typed attributes V , τ from T , or C0,1 or C∗, for some C ∈ C ,
  • atr : C → 2V mapping classes to attributes.

Example:

slide-6
SLIDE 6

That’d Be Too Simple

– 6 – 2015-11-12 – Sstock –

6/27

  • Stereotype1, . . . , Stereotypen
  • Package::C

+ r : C0,1 = expr s : D∗ {ordered} − v : Int = 27 w : Float {readOnly}

A

y : Int

B

{A}

D

x : Int

slide-7
SLIDE 7

What Do We Want / Have to Cover?

– 6 – 2015-11-12 – Sstock –

7/27

A class

  • Stereotype1, . . . , Stereotypen
  • Package::C

+ r : C0,1 = expr s : D∗ {ordered} − v : Int = 27 w : Float {readOnly}

A

y : Int

B

{A}

D

x : Int

  • has a set of stereotypes,
  • has a name,
  • belongs to a package,
  • can be abstract,
  • can be active,
  • has a set of attributes,
  • has a set of operations.

Each attribute has

  • a visibility,
  • a name, a type,
  • a multiplicity, an order,
  • an initial value, and
  • a set of properties, such as readOnly, ordered, etc.

Wanted: places in the signature to represent the information from the picture.

slide-8
SLIDE 8

Extended Signature

– 6 – 2015-11-12 – main –

8/27

slide-9
SLIDE 9

Extended Signature

– 6 – 2015-11-12 – Sextsig –

9/27

  • Definition. An (Extended) Object System Signature is a quadruple

S = (T, C, V, atr ) where

  • T is a set of (basic) types,
  • C is a finite set of classes C, SC, a, t where
  • SC is a finite (possibly empty) set of stereotypes,
  • a ∈ B is a boolean flag indicating whether C is abstract,
  • t ∈ B is a boolean flag indicating whether C is active,
  • V is a finite set of attributes v : T, ξ, expr0, Pv where
  • T is a type from T , or C0,1, C∗ for some C ∈ C ,
  • ξ ∈ {public

:=+

, private

:=−

, protected

  • :=#

, package

  • :=∼

} is the visibility,

  • an initial value expression expr 0 given as a word from a language for

initial value expressions, e.g. OCL, or C++ in the Rhapsody tool,

  • a finite (possibly empty) set of properties Pv.
  • atr : C → 2V maps each class to its set of attributes.

We use SC to denote the set

C∈C SC of stereotypes in S .

slide-10
SLIDE 10

Conventions

– 6 – 2015-11-12 – Sextsig –

10/27

  • We write C, SC, a, t if we want to refer to all aspects of C.
  • If the new aspects are irrelevant (for a given context),

we simply write C i.e. old definitions are still valid.

  • We write v : T, ξ, expr0, Pv if we want to refer to all aspects of v.
  • Write only v : T or v if details are irrelevant.
  • Note:

All definitions we have up to now principally still apply as they are stated in terms of, e.g., C ∈ C — which still has a meaning with the extended view. For instance, system states and object diagrams will remain mostly unchanged.

  • The other way round: most of the newly added aspects do not contribute to

the constitution of system states or object diagrams.

slide-11
SLIDE 11

Mapping UML Class Diagrams to Extended Signatures

– 6 – 2015-11-12 – main –

11/27

slide-12
SLIDE 12

From Class Boxes to Extended Signatures

– 6 – 2015-11-12 – Scdmap –

12/27

A class box n induces an (extended) signature class as follows: n:

  • S1, . . . , Sk
  • C

ξ1 v1 : T1 = expr 1

0 {P1,1, . . . , P1,m1}

. . . ξℓ vℓ : Tℓ = expr ℓ

0 {Pℓ,1, . . . , Pℓ,mℓ}

  • C(n) := C, {S1, . . . , Sk}, a(n), t(n)

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

  • “abstract” is determined by the font:

a(n) =

  • true

, if n = C

  • r n =

C {A} false , otherwise

  • “active” is determined by the frame:

t(n) =

  • true

, if n = C

  • r n =

C false , otherwise

slide-13
SLIDE 13

Example

– 6 – 2015-11-12 – Scdmap –

13/27

  • S1, . . . , Sk
  • C

ξ1 v1 : T1 = expr1

0 {P1,1, . . . , P1,m1}

. . . ξℓ vℓ : Tℓ = exprℓ

0 {Pℓ,1, . . . , Pℓ,mℓ}

  • C(n) := C, {S1, . . . , Sk}, a(n), t(n)

V (n) := {v1 : T1, ξ1, expr1

0, {P1,1, . . . , P1,m1}, . . . ,

vℓ : Tℓ, ξℓ, exprℓ

0, {Pℓ,1, . . . , Pℓ,mℓ}}

atr(n) := {C → {v1, . . . , vℓ}}

  • Stereotype1, . . . , Stereotypen
  • Package::C

+ r : C0,1 = expr s : D∗ {ordered} − v : Int = 27 w : Float {readOnly}

A

y : Int

B

{A}

D

x : Int

slide-14
SLIDE 14

What If Things Are Missing?

– 6 – 2015-11-12 – Scdmap –

14/27

It depends.

  • What does the standard say? (OMG, 2011a, 121)

“Presentation Options. The type, visibility, default, multiplicity, property string may be suppressed from being displayed, even if there are values in the model.”

  • Visibility: There is no “no visibility” — an attribute has a visibility in the

(extended) signature. Some (and we) assume public as default, but conventions may vary.

  • Initial value: some assume it given by domain (such as “leftmost value”, but

what is “leftmost” of Z?). Some (and we) understand non-deterministic initialisation if not given.

  • Properties: probably safe to assume ∅ if not given at all.
slide-15
SLIDE 15

Example Cont’d

– 6 – 2015-11-12 – Scdmap –

15/27

  • S1, . . . , Sk
  • C

ξ1 v1 : T1 = expr1

0 {P1,1, . . . , P1,m1}

. . . ξℓ vℓ : Tℓ = exprℓ

0 {Pℓ,1, . . . , Pℓ,mℓ}

  • C(n) := C, {S1, . . . , Sk}, a(n), t(n)

V (n) := {v1 : T1, ξ1, expr1

0, {P1,1, . . . , P1,m1}, . . . ,

vℓ : Tℓ, ξℓ, exprℓ

0, {Pℓ,1, . . . , Pℓ,mℓ}}

atr(n) := {C → {v1, . . . , vℓ}}

  • Stereotype1, . . . , Stereotypen
  • Package::C

+ r : C0,1 = expr s : D∗ {ordered} − v : Int = 27 w : Float {readOnly}

A

y : Int

B

{A}

D

x : Int

slide-16
SLIDE 16

From Class Diagrams to Extended Signatures

– 6 – 2015-11-12 – Scdmap –

16/27

  • We view a class diagram CD as a graph with nodes {n1, . . . , nN}

(each “class rectangle” is a node).

  • C (CD) := {C(ni) | 1 ≤ i ≤ N}
  • V (CD) := N

i=1 V (ni)

  • atr(CD) := N

i=1 atr(ni)

  • In a UML model, we can have finitely many class diagrams,

C D = {CD1, . . . , CDk}, which induce the following signature: S (C D) =

  • T ,

k

  • i=1

C (CDi),

k

  • i=1

V (CDi),

k

  • i=1

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.)

slide-17
SLIDE 17

Is the Mapping a Function?

– 6 – 2015-11-12 – Scdmap –

17/27

Question: Is S (C D) well-defined?

slide-18
SLIDE 18

References

– 6 – 2015-11-12 – main –

26/27

slide-19
SLIDE 19

References

– 6 – 2015-11-12 – main –

27/27 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¨ at Oldenburg und OFFIS.