Lecture 11: Structural Software Modelling 2017-06-26 Prof. Dr. - - PowerPoint PPT Presentation

lecture 11 structural software modelling
SMART_READER_LITE
LIVE PREVIEW

Lecture 11: Structural Software Modelling 2017-06-26 Prof. Dr. - - PowerPoint PPT Presentation

Softwaretechnik / Software-Engineering Lecture 11: Structural Software Modelling 2017-06-26 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universitt Freiburg, Germany 11 2017-06-26 main Topic Area Architecture


slide-1
SLIDE 1

– 11 – 2017-06-26 – main –

Softwaretechnik / Software-Engineering

Lecture 11: Structural Software Modelling

2017-06-26

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

Albert-Ludwigs-Universität Freiburg, Germany

slide-2
SLIDE 2

Topic Area Architecture & Design: Content

– 11 – 2017-06-26 – Sblockcontent –

2/51

  • Introduction and Vocabulary
  • Software Modelling

(i) views and viewpoints, the 4+1 view (ii) model-driven/-based software engineering (iii) Unified Modelling Language (UML) (iv) Modelling structure a) (simplified) class diagrams b) (simplified) object diagrams c) (simplified) object constraint logic (OCL) (v) Principles of Design a) modularity b) separation of concerns c) information hiding and data encapsulation d) abstract data types, object orientation (vi) Modelling behaviour a) communicating finite automata b) Uppaal query language c) basic state-machines d) an outlook on hierarchical state-machines

  • Design Patterns

VL 10 . . . VL 11 . . . VL 12 . . . VL 13 . . .

slide-3
SLIDE 3

Content

– 11 – 2017-06-26 – Scontent –

3/51

  • Software Modelling
  • views & viewpoints
  • the 4+1 view
  • Class Diagrams
  • concrete syntax,
  • abstract syntax,
  • class diagrams at work,
  • semantics: system states.
  • Object Diagrams
  • concrete syntax,
  • dangling references,
  • partial vs. complete,
  • object diagrams at work.
  • Software Modelling Cont’d
  • An outlook on UML
  • model-driven software engineering
slide-4
SLIDE 4

– 11 – 2017-06-26 – main –

4/51

Example: Design-Models in Construction Engineering

– 10 – 2017-06-22 – Smodel –

45/60

  • 1. Requirements
  • Shall fit on given

piece of land.

  • Each room shall

have a door.

  • Furniture shall fit

into living room.

  • Bathroom shall

have a window.

  • Cost shall be in

budget.

  • 2. Designmodel

http://wikimedia.org (CC nc-sa 3.0, Ottoklages)

  • 3. System

http://wikimedia.org (CC nc-sa 3.0, Bobthebuilder82)

Observation (1): Floorplan abstracts from certain system properties, e.g. ...

  • kind, number, and placement of bricks,
  • subsystem details (e.g., window style),
  • water pipes/wiring, and
  • wall decoration

architects can efficiently work on appropriate level of abstraction

slide-5
SLIDE 5

– 11 – 2017-06-26 – main –

5/51

Example: Design-Models in Construction Engineering

– 10 – 2017-06-22 – Smodel –

45/60

  • 1. Requirements
  • Shall fit on given

piece of land.

  • Each room shall

have a door.

  • Furniture shall fit

into living room.

  • Bathroom shall

have a window.

  • Cost shall be in

budget.

  • 2. Designmodel

http://wikimedia.org (CC nc-sa 3.0, Ottoklages)

  • 3. System

http://wikimedia.org (CC nc-sa 3.0, Bobthebuilder82)

Observation (2): Floorplan preserves/determines certain system properties, e.g.,

  • house and room extensions (to scale),
  • presence/absence of windows and doors,
  • placement of subsystems

(such as windows). find design errors before building the system (e.g. bathroom windows)

slide-6
SLIDE 6

– 11 – 2017-06-26 – main –

6/51

slide-7
SLIDE 7

– 11 – 2017-06-26 – main –

7/51

Model

– 10 – 2017-06-22 – Smodel –

43/60

  • Definition. (Folk) A model is an abstract, formal, mathematical representation or description
  • f structure or behaviour of a (software) system.
  • Definition. (Glinz, 2008, 425)

A model is a concrete or mental image (Abbild) of something

  • r a concrete or mental archetype (Vorbild) for something.

Three properties are constituent: (i) the image attribute (Abbildungsmerkmal), i.e. there is an entity (called original) whose image or archetype the model is, (ii) the reduction attribute (Verkürzungsmerkmal), i.e. only those attributes of the original that are relevant in the modelling context are represented, (iii) the pragmatic attribute, i.e. the model is built in a specific context for a specific purpose.

slide-8
SLIDE 8

Software Modelling

– 11 – 2017-06-26 – main –

8/51

slide-9
SLIDE 9

Views and Viewpoints

– 11 – 2017-06-26 – Sswmodel –

9/51 view — A representation of a whole system from the perspective of a related set of concerns.

IEEE 1471 (2000)

viewpoint — A specification of the conventions for constructing and using a view. A pat- tern or template from which to develop individual views by establishing the purposes and audience for a view and the techniques for its creation and analysis.

IEEE 1471 (2000)

  • A perspective is determined by concerns and information needs:
  • team leader, e.g., needs to know which team is working on what component,
  • operator, e.g., needs to know which component is running on which host,
  • developer, e.g., needs to know interfaces of other components.
  • etc.
slide-10
SLIDE 10

An Early Proposal: The 4+1 View (Kruchten, 1995)

– 11 – 2017-06-26 – Sswmodel –

10/51

Logical View Development View Process View Physical View Scenarios

end-user functionality programmers, software management integrators, performance, scalability system engineers, topology, communication

Newer proposals (Ludewig and Lichter, 2013): system view: how is the system under development integrated into (or seen by) its environment; with which other systems (including users) does it interact how. static view (∼ developer view): components of the architecture, their interfaces and relations. Possibly: assignment of development, test, etc.

  • nto teams.

dynamic view (∼ process view): how and when are components instantiated and how do they work together at runtime. deployment view (∼ physical view): how are component instances mapped onto infrastructure and hardware units.

“Purpose of architecture: support functionality; functionality is not part of the architecture.” ?!

slide-11
SLIDE 11

Deployment / Physical View

– 11 – 2017-06-26 – Sswmodel –

11/51

http://products.bosch-mobility-solutions.com/en/de/driving_safety/ driving_safety_systems_for_commercial_vehicles/electronic_systems_1/ electronic_systems_3.html — Robert Bosch GmbH

Example: modern cars

  • large number of electronic control units (ECUs) spread all over the car,
  • which part of the overall software is running on which ECU?
  • which function is used when? Event triggered, time triggered, continuous, etc.?

For, e.g., a simple smartphone app, process and physical view may be trivial or determined by the employed framework (→ later) — so no need for (extensive) particular documentation.

slide-12
SLIDE 12

Structure vs. Behaviour / Constructive vs. Reflective

– 11 – 2017-06-26 – Sswmodel –

12/51

  • Definition. Software is a finite description S of a (possibly in-

finite) set S of (finite or infinite) computation paths of the form σ0

α1

− − → σ1

α2

− − → σ2 · · · where

  • σi ∈ Σ, i ∈ N0, is called state (or configuration), and
  • αi ∈ A, i ∈ N0, is called action (or event).

The (possibly partial) function · : S → S is called inter- pretation of S.

  • Form of the states in Σ (also actions A):

structure of S

  • Computation paths π of S:

behaviour of S (Harel, 1997) proposes to distinguish constructive and reflective descriptions

  • f behaviour:
  • constructive:

“constructs [of description] contain information needed in executing the model or in translating it into executable code.” → how things are computed.

  • reflective (or assertive):

“[description used] to derive and present views of the model, statically or during execution,

  • r to set constraints on behavior in preparation for verification.”

→ what should (or should not) be computed. Note: No sharp boundaries! (would be too easy...)

slide-13
SLIDE 13

Views and Their Representation

– 11 – 2017-06-26 – Sswmodel –

13/51

(Σ × A)ω

Analyst

Tron Joystick? ... Keyboard? Control Player colour score direction speed Gameplay Render OpenGL? ... aalib? AI? Segment x0, y0 x1, y1 colour Engine areawidth areaheight

1..∗ notify update 0..∗ head world 1..∗

Main External inputs

  • Keyboard
  • Joystick
  • ...

Game Logic

  • player scores
  • interface inputs/engine

(Physics) Engine

  • physical objects
  • collision notification

Output

  • Graphics (from ASCII
to bitmap; native or via API)
  • Sound
  • ...

notify update ? ?

  • n
  • w

e s resigned

X/

LSC: name AC: true AM: invariant I: permissive User Game

slide-14
SLIDE 14

Topic Area Architecture & Design: Content

– 11 – 2017-06-26 – Sblockcontent –

15/51

  • Introduction and Vocabulary
  • Software Modelling

(i) views and viewpoints, the 4+1 view (ii) model-driven/-based software engineering (iii) Unified Modelling Language (UML) (iv) Modelling structure a) (simplified) class diagrams b) (simplified) object diagrams c) (simplified) object constraint logic (OCL) (v) Principles of Design a) modularity b) separation of concerns c) information hiding and data encapsulation d) abstract data types, object orientation (vi) Modelling behaviour a) communicating finite automata b) Uppaal query language c) basic state-machines d) an outlook on hierarchical state-machines

  • Design Patterns

VL 10 . . . VL 11 . . . VL 12 . . . VL 13 . . .

slide-15
SLIDE 15

Content

– 11 – 2017-06-26 – Scontent –

16/51

  • Software Modelling
  • views & viewpoints
  • the 4+1 view
  • Class Diagrams
  • concrete syntax,
  • abstract syntax,
  • class diagrams at work,
  • semantics: system states.
  • Object Diagrams
  • concrete syntax,
  • dangling references,
  • partial vs. complete,
  • object diagrams at work.
  • Software Modelling Cont’d
  • An outlook on UML
  • model-driven software engineering
slide-16
SLIDE 16

– 11 – 2017-06-26 – main –

17/51

... so, off to “ ‘technological paradise’ where [...] everything happens according to the blueprints”.

(Kopetz, 2011; Lovins and Lovins, 2001)

slide-17
SLIDE 17

Class Diagrams

– 11 – 2017-06-26 – main –

18/51

slide-18
SLIDE 18

Class Diagrams: Concrete Syntax

– 11 – 2017-06-26 – Sumlsig –

19/51

C

v1 : T1 . . . vn : Tn f1(T1,1, . . . , T1,n1) : T1,0 . . . fm(Tm,1, . . . , Tm,nm) : Tm,0

D

class class name typed attributes typed methods attributes compartment methods compartment where

  • T1, . . . , Tm,0 ∈ T ∪ {C0,1, C∗ | C a class name}
  • T is a set of basic types, e.g. Int, Bool, . . . .
slide-19
SLIDE 19

Concrete Syntax: Example

– 11 – 2017-06-26 – Sumlsig –

20/51 C

n : C∗ p : C0,1

D

x : Int p : C0,1 f(Int) : Bool get_x() : Int x : Int p : C0,1

Alternative notation for C0,1 and C∗ typed attributes:

C D

x : Int f(Int) : Bool get_x() : Int

  • p

0..1 ×

  • p

0..1 ×

  • n

0..∗ ×

Alternative lazy notation for alternative notation:

C D

x : Int f(Int) : Bool get_x() : Int p 0..1 p 0..1 n 0..∗

And nothing else! This is the concrete syntax of class diagrams for the scope of the course.

slide-20
SLIDE 20

Abstract Syntax: Object System Signature

– 11 – 2017-06-26 – Sumlsig –

21/51

  • Definition. An (Object System) Signature is a 6-tuple

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

  • T is a set of (basic) types,
  • C is a finite set of classes,
  • V is a finite set of typed attributes v : T, i.e., each v ∈ V has type T,
  • atr : C → 2V maps each class to its set of attributes.
  • F is a finite set of typed behavioural features f : T1, . . . , Tn → T,
  • mth : C → 2F maps each class to its set of behavioural features.
  • A type can be a basic type τ ∈ T , or C0,1, or C∗, where C ∈ C .

Note: Inspired by OCL 2.0 standard OMG (2006), Annex A.

slide-21
SLIDE 21

Object System Signature Example

– 11 – 2017-06-26 – Sumlsig –

22/51

  • Definition. An (Object System) Signature is a 6-tuple

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

  • T is a set of (basic) types,
  • C is a finite set of classes,
  • V is a finite set of typed attributes v : T, i.e., each v ∈ V has type T,
  • atr : C → 2V maps each class to its set of attributes.
  • F is a finite set of typed behavioural features f : T1, . . . , Tn → T,
  • mth : C → 2F maps each class to its set of behavioural features.
  • A type can be a basic type τ ∈ T , or C0,1, or C∗, where C ∈ C .

S0 = ({Int, Bool}, {C, D}, {x : Int, p : C0,1, n : C∗}, {C → {p, n}, D → {p, x}}, {f : Int → Bool, get_x : Int}, {C → ∅, D → {f, get_x}})

slide-22
SLIDE 22

From Abstract to Concrete Syntax

– 11 – 2017-06-26 – Sumlsig –

23/51 C D

x : Int f(Int) : Bool get_x() : Int

p 0..1 p 0..1 n 0..∗

S = (T, C, V, atr , F, mth)

  • T ={Int, Bool}
  • C ={C, D}
  • V ={x : Int, p : C0,1, n : C∗}
  • atr ={C → {p, n}, D → {p, x}}
  • F ={f : Int → Bool, get_x : Int}
  • mth ={C → ∅, D → {f, get_x}}
slide-23
SLIDE 23

Once Again: Concrete vs. Abstract Syntax

– 11 – 2017-06-26 – Sumlsig –

24/51

S0 = ({Int, Bool}, {C, D}, {x : Int, p : C0,1, n : C∗}, {C → {p, n}, D → {p, x}}, {f : Int → Bool, get_x : Int}, {C → ∅, D → {f, get_x}})

C

n : C∗ p : C0,1

D

x : Int p : C0,1 f(Int) : Bool get_x() : Int x : Int p : C0,1

C D

x : Int f(Int) : Bool get_x() : Int

  • p

0..1 ×

  • p

0..1 ×

  • n

0..∗ × C D

x : Int f(Int) : Bool get_x() : Int

p 0..1 p 0..1 n 0..∗ D

x : Int f(Int) : Bool get_x() : Int

C p 0..1 p 0..1 n 0..∗ C

n : C∗ p : C0,1

D

x : Int p : C0,1 f(Int) : Bool get_x() : Int x : Int p : C0,1

C D

x : Int f(Int) : Bool get_x() : Int

p 0..1 p 0..1 n 0..∗

slide-24
SLIDE 24

Class Diagrams at Work

– 11 – 2017-06-26 – main –

25/51

slide-25
SLIDE 25

Visualisation of Implementation

– 11 – 2017-06-26 – Scdatwork –

26/51

  • The class diagram syntax can be used to visualise code:

provide rules which map (parts of) the code to class diagram elements.

1

package pac ;

2 3

import pac .D;

4 5

public c lass C {

6 7

public D n ;

8 9

public void print_nx ( ) {

10

System . out . p r i n t f (

11

"%i \n" , n . get_x ( ) ) ; } ;

12 13

public C ( ) { } ;

14

}

1

package pac ;

2 3

import pac . C ;

4 5

public c lass D {

6 7

private int x ;

8 9

public int get_x ( )

10

{ return x ; } ;

11 12

public D ( ) { } ;

13

}

pac

C

print_nx(); C();

D

x : int get_x() : int; D(); n 0..1

slide-26
SLIDE 26

Visualisation of Implementation: (Useless) Example

– 11 – 2017-06-26 – Scdatwork –

27/51

  • open favourite IDE,
  • open favourite project,
  • press “generate class diagram”
  • wait...wait...wait...
cd UMLClassDiagram1 Byteco…torCall «C# class» Attributes + containingType : IT…
  • isDeferringCtor : Boo…
Operations + IsDeferringCtor(met… + TraverseChildren(m…
  • FindCtorCall(containi…
Byteco…antics «C# class» Attributes Operations + CLRExpressionSema… Byteco…nalyzer «C# class» Attributes
  • currentCatchClauseE…
  • exceptionsThrown :...
  • parent : ExceptionAn…
Operations + ExplicitlyThrownEx... + TraverseChildren(m… + TraverseChildren(tr… + TraverseChildren(ca… + TraverseChildren(re… + TraverseChildren(th…
  • MethodExceptionAna…
Byteco…mplifier «C# class» Attributes
  • sink : Sink
Operations + Rewrite(arrayIndex… + Rewrite(boundExpr… + Rewrite(targetExpre… + Simplify(sink : Sink, …
  • ExpressionSimplifier(…
Byteco…averser «C# delegate» Attributes Operations + Invoke(source : IEx… Byteco…mparer «C# class» Attributes Operations + Equals(x : IFieldRef… + FieldComparer() + GetHashCode(obj : … Byteco…mparer «C# class» Attributes Operations + Equals(x : IMethod… + GetHashCode(obj : … + MethodComparer() Byteco…ypeInfo «C# class» Attributes + Constructor : Functi… + ConstructorId : Con…
  • constructor : Function
  • constructorId : Cons…
  • typeParameterToSel...
Operations + Selector(typeParam… + TypeInfo(sink : Sink… Byteco…Emitter «C# class» Attributes
  • parent : StatementT…
Operations + SourceContextEmitt… + Visit(statement : ISt…
  • EmitSourceContext(s…
Byteco…antics «C# class» Attributes + subTypes : Diction...
  • parent : WholeProgr…
Operations + GetExplicitlyImple... + TraverseChildren(m… + WholeProgramExpr…
  • FindOverrides(type ...
Byteco…antics «C# class» Attributes
  • codeUnderAnalysis :...
  • parent : WholeProgr…
  • sink : Sink
Operations + TranslateAssemblie... + WholeProgramMet... Byteco…nslator «C# class» Attributes + Factory : TraverserF…
  • contractProviders :
...
  • pdbReaders :
IDicti...
  • sink : Sink
  • traverser : BCTMeta…
Operations + BaseTranslator(fact... + getModifiedIdentifi... + getPostconditionTr... + getPreconditionTra... + getPriority() : Integer + initialize() + isOneShot() : Boolean + TranslateAssemblie... Byteco…or::BCT «C# class» Attributes + Host : IMetadataHost
  • modules :
List<IMo... Operations + BCT() + Inline(bplFileName : … + TranslateAssembly(... + TranslateAssembly...
  • BuildAssignment(sin...
  • BuildIfCmd(b : Expr,
  • BuildIfCmd(b : Expr,
  • BuildReturnCmd(b :
  • BuildStmtList(cmd :
  • callPostTranslationT...
  • checkTransitivelyCal...
  • CreateDelegateAdd...
  • CreateDelegateCrea...
  • CreateDelegateRem...
  • CreateDispatchMeth...
  • createPhoneBoogieC…
  • EmitDummySourceC…
  • finalizeNavigationAn…
  • GenerateInAndOutE...
  • Main(args : String[*]…
  • NameUpToFirstPerio…
  • outputBackKeyWarni…
  • outputBoogieTracke…
Byteco…averser «C# class» Attributes + Factory : TraverserF… + PdbReader : PdbRe… + PdbReaders : IDicti...
  • entryPoint : IMethod…
  • privateTypes :
List<...
  • sawCctor : Boolean
  • sink : Sink
Operations + BCTMetadataTrave... + getModifiedIdentifi... + getPostconditionTr... + getPreconditionTra... + GetTypeDefinitionF... + TranslateAssemblie... + TraverseChildren(m… + TraverseChildren(ty… + TraverseChildren(as… + TraverseChildren(fie… + TraverseChildren(m…
  • addPhoneTopLevelD…
  • CreateDefaultStructC…
  • CreateStaticConstruc…
  • CreateStructCopyCo…
  • InitializeFieldsInCon...
  • IsStubMethod(metho…
  • trackControlVariable…
  • trackNavigationVaria…
  • trackPhoneApplicatio…
  • trackPhonePageNam…
Byteco…antics «C# class» Attributes Operations + CLRSemantics() + getTranslator(sink :... + MakeExpressionTra… Byteco…btypes «C# class» Attributes
  • subTypes :
Dictiona...
  • visitedTypes :
Hash... Operations + RecordSubtypes(su... + TraverseChildren(ty… Byteco…nalyzer «C# class» Attributes
  • exceptionsExplicitly...
  • resultsChanged : Bo…
Operations + ComputeExplicitlyT... + TraverseChildren(m…
  • ExceptionAnalyzer()
Byteco…averser «C# class» Attributes + TranslatedExpressi...
  • contractContext : Bo…
  • currentExpressionIs…
# sink : Sink # StmtTraverser : Sta… Operations + ExpressionTraverser… + IsConversionOperat… + IsOperator(method… + TraverseChildren(m… + TraverseChildren(ad… + TraverseChildren(ad… + TraverseChildren(ad… + TraverseChildren(ad… + TraverseChildren(ar… + TraverseChildren(as… + TraverseChildren(bit… + TraverseChildren(bit… + TraverseChildren(bl… + TraverseChildren(bo… + TraverseChildren(ca… + TraverseChildren(ch… + TraverseChildren(co… + TraverseChildren(co… + TraverseChildren(co… + TraverseChildren(cr… + TraverseChildren(cr… + TraverseChildren(cr… + TraverseChildren(de… + TraverseChildren(di… + TraverseChildren(du… + TraverseChildren(eq… + TraverseChildren(ex… + TraverseChildren(gr… + TraverseChildren(gr… + TraverseChildren(lef… + TraverseChildren(le… + TraverseChildren(le… + TraverseChildren(lo… + TraverseChildren(m… + TraverseChildren(m… + TraverseChildren(no… + TraverseChildren(ol… + TraverseChildren(on… + TraverseChildren(po… + TraverseChildren(re… + TraverseChildren(ri… + TraverseChildren(su… + TraverseChildren(ta… + TraverseChildren(th… + TraverseChildren(ty… + TraverseChildren(un… + TraverseChildren(ve…
  • AssertOrAssumeNon…
  • BooleanValueOfCom…
  • EmitLineDirective(m…
  • handleStructConstr...
  • IsConstantNull(iExpr…
  • LoadAddressOf(cont…
  • LoadParameter(para…
  • PossiblyCoerceRefTo…
  • ResolveUnspecialize…
  • translateAddRemov...
  • TranslateAssignment…
  • TranslateDelegateCr…
  • TranslateHavocCurre…
  • translateStructDefaul…
  • TraverseAdditionRig…
  • TraverseBitwiseAndR…
  • TraverseBitwiseOrRi…
  • TraverseDivisionRigh…
  • TraverseExclusiveOr…
  • TraverseLeftShiftRig…
  • TraverseModulusRig…
  • TraverseMultiplicatio…
  • TraverseRightShiftRi…
  • TraverseSubtraction…
  • VisitAssignment(targ…
# TranslateArgument... ~ IsAtomicInstance(e… Byteco…ralHeap «C# class» Attributes
  • HeapVariable : Varia…
  • InitialPreludeText : S…
  • Read : Function
  • sink : Sink
  • Write : Function
Operations + CreateEventVariable… + CreateFieldVariable(… + GeneralHeap() + MakeHeap(sink : Si… + ReadHeap(o : Expr, … + WriteHeap(tok : ITo… «C# class» Attributes + AllocConstBool : Fu… + AllocImplies : Functi… + AllocVariable : Varia… + ArrayContentsVaria… + ArrayLengthFunctio… + AsFunction : Function + BitwiseAnd : Function + BitwiseExclusiveOr : … + BitwiseNegation : F… + BitwiseOr : Function + Bool2Union : Function + BoolValueType : Co… + BoxFromBool : Proc… + BoxFromInt : Proce… + BoxFromReal : Proc… + BoxFromUnion : Pro… + DefaultHeapValue : … + DefaultReal : Const… + DisjointSubtree : Fu… + ExceptionVariable : … + FieldType : CtorType + FieldTypeDecl : Typ… + Int2Real : Function + Int2Union : Function + IntValueType : Con… + LeftShift : Function + NullRef : Constant + Real2Int : Function + Real2Union : Function + RealDivide : Function + RealGreaterThan : F… + RealGreaterThanOr… + RealLessThan : Fun… + RealLessThanOrEqu… + RealMinus : Function + RealModulus : Func… + RealPlus : Function + RealTimes : Function + RealType : CtorType + RealValueType : Co… + RefToDelegateMeth… + RefToDelegateRecei… + RefToDelegateType… + RefType : CtorType + RefTypeDecl : Type… + RightShift : Function + Subtype : Function + TypeConstructorFun… + TypeType : Type + TypeTypeDecl : Typ… + Unbox2Bool : Functi… + Unbox2Int : Function + Unbox2Real : Functi… + Unbox2Union : Fun… + Union2Bool : Function + Union2Int : Function + Union2Real : Function + UnionType : Type + UnionTypeDecl : Ty… # CommonText : String # DynamicTypeFuncti… # RealTypeDecl : Typ… Operations + CreateTypeFunction… + CreateTypeVariable... + DynamicType(o : Ex… + FromUnion(tok : IT… + Heap() + ToUnion(tok : IToke… «C# class» Attributes Operations + HeapFactory() Byteco…ameter «C# class» Attributes + inParameterCopy : … + outParameterCopy : … + underlyingParamete… Operations + MethodParameter(p… + ToString() : String Byteco…averser «C# class» Attributes
  • currStatement : ITry…
  • mostNestedTryState...
Operations + MostNestedTryState… + MostNestedTryState… + TraverseChildren(tr… + TraverseChildren(la… Byteco…Module «C# class» Attributes
  • sourceUnit : IUnit
  • targetUnit : IUnit
Operations + ReparentModule(ho… + RewriteChildren(roo… Byteco…Options «C# class» Attributes + assemblies : List<S... + breakIntoDebugger … + captureState : Bool… + dereference : Deref… + exemptionFile : String + getMeHere : Boolean + heapRepresentation … + instrumentBranches … + libpaths : List<Stri... + modelExceptions : I… + monotonicHeap : B… + phoneControls : Stri… + phoneFeedbackCod… + phoneNavigationCo… + stub : List<String > + wholeProgram : Bo… Operations + Options() Byteco…Prelude «C# class» Attributes Operations + Emit(wr : TokenTex… + Prelude() Byteco…mparer «C# class» Attributes
  • resolveTypes : Boole…
~ instance : RelaxedT… ~ resolvingInstance : … Operations + Equals(x : ITypeRef… + GetHashCode(r : IT…
  • RelaxedTypeEquival…
Byteco…tionFor «C# class» Attributes ~ declaration : String ~ name : String ~ required : Boolean Operations ~ ParsePrelude(initial… ~ RepresentationFor(… ~ RepresentationFor(… Byteco…r::Sink «C# class» Attributes + AllocationMethodNa… + cciLabels : Dictiona... + delegateTypeToDel... + delegateTypeToDel... + delegateTypeToDel... + delegateTypeToDel... + Heap : Heap + initiallyDeclaredPro... + LabelVariable : Loca… + LocalCounter : Inte… + LocalExcVariable : L… + LocalVarMap : Dicti... + MethodThrowsExce... + nestedTryCatchFin... + Options : Options + ReferenceTypeNam… + ReturnVariable : For… + StaticFieldFunction : … + ThisVariable : Formal + TranslatedProgram … + TranslationPlugins ... + tryCatchFinallyIden... + UniqueNumberAcro…
  • arityToNaryIntFunct...
  • arityToNaryTypeFun...
  • assemblyBeingTransl…
  • declaredEvents :
Di...
  • declaredFields :
Dic...
  • declaredMethods :
...
  • declaredProperties :...
  • declaredRealConsta...
  • declaredStringConst...
  • declaredStructCopy...
  • declaredStructDefa...
  • declaredStructEqual...
  • declaredTypeConsta...
  • declaredTypeFuncti...
  • declaredTypeParam...
  • delegateMethods :
...
  • escapingGotoEdges ...
  • exemptionList :
List...
  • globalVariables :
IDi...
  • heap : Heap
  • localCounter : Integer
  • localVarMap :
Dictio...
  • methodBeingTransla…
  • mostNestedTryState…
  • options : Options
  • projectionFunctions ...
  • thisVariable : Formal
  • translationPlugins :
...
  • typeParameterFunct...
  • uniqueNumberSeed
  • whiteList : Boolean
~ host : IContractAwa… ~ operandStack : Sta... Operations + AddDelegate(type : … + AddDelegateType(t… + AddEscapingEdge(tr… + BeginAssembly(asse… + BeginMethod(metho… + BeginMethod(contai… + CciTypeToBoogie(ty… + ConsolidatedGeneri… + CreateFreshLocal(ty… + CreateFreshLocal(t : … + DelegateAdd(type : … + DelegateCreate(typ… + DelegateRemove(ty… + EndAssembly(asse… + EscapingEdges(try... + FindOrCreateCatchL… + FindOrCreateCciLab… + FindOrCreateConsta… + FindOrCreateConsta… + FindOrCreateConsta… + FindOrCreateContin… + FindOrCreateDelega… + FindOrCreateEventV… + FindOrCreateFieldV… + FindOrCreateFinally… + FindOrCreateGlobal… + FindOrCreateLocalV… + FindOrCreateNaryIn… + FindOrCreateNaryTy… + FindOrCreateProced… + FindOrCreateProced… + FindOrCreateProced… + FindOrCreateProper… + FindOrCreateTypeP… + FindOrCreateTypeR… + FindOrCreateTypeR… + FindOrDefineType(t… + FindOrDefineTypeP… + FindParameterVaria… + GenerateDynamicTy… + GetConsolidatedTy... + getMethodBeingTra… + GetNumberTypePar… + GetUninstantiatedG… + MostNestedTryState… + ReadMethod(metho… + ReadReceiver(meth… + ReadTypeParameter… + Sink(host : IContra... + TranslateType(t : IT… + Unspecialize(metho…
  • DeclareParents(type…
  • DeclareParentsNew(t…
  • DeclareSuperType(ty…
  • FindOrDefineTypeCo…
  • GetParents(typeDefi...
  • IsPure(method : IMe…
  • IsStubMethod(metho…
~ CreateIdentifierCorr… Sink * Heap 1 Sink * Opti… 1 Byteco…dsHeap «C# class» Attributes
  • InitialPreludeText : S…
  • sink : Sink
Operations + CreateEventVariable… + CreateFieldVariable(… + MakeHeap(sink : Si… + ReadHeap(o : Expr, … + SplitFieldsHeap() + WriteHeap(tok : ITo… Byteco…averser «C# class» Attributes + factory : TraverserF… + lastSourceLocation : … + PdbReader : PdbRe… + StmtBuilder : StmtLi…
  • captureState : Boolean
  • captureStateCounter
  • contractContext : Bo…
  • sink : Sink
Operations + GenerateDispatchC… + RaiseException(e : … + RaiseException() + StatementTraverser… + TranslateMethod(m... + TraverseChildren(tr… + TraverseChildren(as… + TraverseChildren(as… + TraverseChildren(bl… + TraverseChildren(br… + TraverseChildren(co… + TraverseChildren(co… + TraverseChildren(do… + TraverseChildren(ex… + TraverseChildren(fo… + TraverseChildren(fo… + TraverseChildren(go… + TraverseChildren(la… + TraverseChildren(lo… + TraverseChildren(pu… + TraverseChildren(re… + TraverseChildren(re… + TraverseChildren(s… + TraverseChildren(th… + TraverseChildren(w…
  • ExpressionFor(expre…
  • RaiseExceptionHelpe…
Byteco…ception «C# class» Attributes Operations + TranslationExceptio… + TranslationExceptio… Byteco…Helper «C# class» Attributes ~ catchClauseCounter … ~ finallyClauseCounte… ~ tmpVarCounter : Int… Operations + BuildAssignCmd(le... + BuildAssignCmd(lhs … + BuildStmtList(cmds … + BuildStmtList(cmd : … + BuildStmtList(tcmd … + ConsolidatedGeneri... + CreateUniqueMetho… + GenerateCatchClaus… + GenerateFinallyClau… + GenerateTempVarN… + IsStruct(typ : IType… + Token(objectWithLo… + TurnStringIntoValid…
  • ConsolidatedGeneri...
  • GetRidOfSurrogateC…
«C# class» Attributes + Priority : Integer Operations + getTranslator(sink :... + MakeExpressionTra… + MakeMetadataTrav... + MakeStatementTrav… + TraverserFactory() Byteco…erences «C# class» Attributes
  • internedKeys :
Dicti...
  • sourceUnitIdentity :
… ~ originalAssemblyIde… ~ targetAssembly : IA… Operations + Rewrite(assemblyRe… + Rewrite(moduleRef… + RewriteUnitReferen… Byteco…rogram «C# class» Attributes + subTypes : Diction... Operations + getTranslator(sink :... + MakeExpressionTra… + MakeMetadataTrav... + WholeProgram()
  • ca. 35 classes,
  • ca. 5,000 LOC C#
slide-27
SLIDE 27

Visualisation of Implementation: (Useful) Example

– 11 – 2017-06-26 – Scdatwork –

28/51

Tron Joystick? ... Keyboard? Control Player

colour score direction speed

Gameplay Render OpenGL? ... aalib? AI? Segment

x0, y0 x1, y1 colour

Engine

areawidth areaheight

1..∗ notify update 0..∗ head world 1..∗

  • A diagram is a good diagram if (and only if?) it serves its purpose!
  • Note: a class diagram for visualisation may be partial.

→ show only the most relevant classes and attributes (for the given purpose).

  • Note: a signature can be defined by a set of class diagrams.

→ use multiple class diagrams with a manageable number of classes for different purposes.

slide-28
SLIDE 28

Literature Recommendation

– 11 – 2017-06-26 – Scdatwork –

29/51

(Ambler, 2005)

slide-29
SLIDE 29

A More Abstract Class Diagram Semantics

– 11 – 2017-06-26 – main –

30/51

slide-30
SLIDE 30

Object System Structure

– 11 – 2017-06-26 – Sumlstruc –

31/51

  • Definition. An Object System Structure of signature

S = (T, C, V, atr , F, mth) is a domain function D which assigns to each type a domain, i.e.

  • τ ∈ T is mapped to D(τ),
  • C ∈ C is mapped to an infinite set D(C) of (object) identities.
  • object identities of different classes are disjoint, i.e.

∀ C, D ∈ C : C = D → D(C) ∩ D(D) = ∅,

  • on object identities, (only) comparision for equality “=” is defined.
  • C∗ and C0,1 for C ∈ C are mapped to 2D(C).

We use D(C ) to denote

C∈C D(C); analogously D(C∗).

Note: We identify objects and object identities, because both uniquely determine each other (cf. OCL 2.0 standard).

slide-31
SLIDE 31

Basic Object System Structure Example

– 11 – 2017-06-26 – Sumlstruc –

32/51

Wanted: a structure for signature S0 = ({Int, Bool}, {C, D}, {x : Int, p : C0,1, n : C∗}, {C → {p, n}, D → {p, x}}, {f : Int → Bool, get_x : Int}, {C → ∅, D → {f, get_x}})

A structure D maps

  • τ ∈ T to some D(τ), C ∈ C to some identities D(C) (infinite, pairwise disjoint),
  • C∗ and C0,1 for C ∈ C to D(C0,1) = D(C∗) = 2D(C).

D(Int) = Z D(C) = N+ × {C} ∼ = {1C, 2C, 3C, ...} D(D) = N+ × {D} ∼ = {1D, 2D, 3D, ...} D(C0,1) = D(C∗) = 2D(C) D(D0,1) = D(D∗) = 2D(D)

slide-32
SLIDE 32

System State

– 11 – 2017-06-26 – Sumlstruc –

33/51

  • Definition. Let D be a structure of S = (T, C, V, atr , F, mth).

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(σ)

  • dom(σ(u)) = atr(C)
  • σ(u)(v) ∈ D(τ) if v : τ, τ ∈ T
  • σ(u)(v) ∈ D(D∗) if v : D0,1 or v : D∗ with D ∈ C

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.

slide-33
SLIDE 33

System State Examples

– 11 – 2017-06-26 – Sumlstruc –

34/51 S0 = ({Int, Bool}, {C, D}, {x : Int, p : C0,1, n : C∗}, {C → {p, n}, D → {p, x}}, {f : Int → Bool, get_x : Int}, {C → ∅, D → {f, get_x}}) D(Int) = Z, D(C) = {1C, 2C, 3C, ...}, D(D) = {1D, 2D, 3D, ...} A system state is a partial function σ : D(C ) (V (D(T ) ∪ D(C∗))) such that

  • dom(σ(u)) = atr(C),
  • σ(u)(v) ∈ D(τ) if v : τ, τ ∈ T ,
  • σ(u)(v) ∈ D(C∗) if v : D∗ or v : D0,1 with D ∈ C .
slide-34
SLIDE 34

Content

– 11 – 2017-06-26 – Scontent –

35/51

  • Software Modelling
  • views & viewpoints
  • the 4+1 view
  • Class Diagrams
  • concrete syntax,
  • abstract syntax,
  • class diagrams at work,
  • semantics: system states.
  • Object Diagrams
  • concrete syntax,
  • dangling references,
  • partial vs. complete,
  • object diagrams at work.
  • Software Modelling Cont’d
  • An outlook on UML
  • model-driven software engineering
slide-35
SLIDE 35

Object Diagrams

– 11 – 2017-06-26 – main –

36/51

slide-36
SLIDE 36

Object Diagrams

– 11 – 2017-06-26 – Sod –

37/51 S0 = ({Int, Bool}, {C, D}, {x : Int, p : C0,1, n : C∗}, {C → {p, n}, D → {p, x}}, {f : Int → Bool, get_x : Int}, {C → ∅, D → {f, get_x}}), D(Int) = Z

σ = {1C → {p → ∅, n → {5C}}}, 5C → {p → ∅, n → ∅}, 1D → {p → {5C}, x → 23}}

Concrete Syntax:

id : class v1 = d1 . . . vn = dn id : class r

  • ptional

mandatory

  • “compartment”
  • ptional
  • ptional
  • We may represent σ graphically as follows:

1C : C p = ∅ n = {1D} 5C : C p = ∅ n = ∅ 1D : D p = {1D} x = 23

This is an object diagram.

  • Alternative notation:

1C : C p = ∅ 5C : C p = ∅ n = ∅ 1D : D x = 23 n p

  • Alternative non-standard notation:

1C : C 5C : C 1D : D x = 23 n p | p | p | n

slide-37
SLIDE 37

Special Case: Dangling Reference

– 11 – 2017-06-26 – Sod –

38/51

Definition. Let σ ∈ ΣD

S be a system state and u ∈ dom(σ) an alive object of class C in σ.

We say r ∈ atr(C) is a dangling reference in u if and only if r : C0,1 or r : C∗ and u refers to a non-alive object via v, i.e. σ(u)(r) ⊂ dom(σ).

Example:

  • σ = {1C → {p → ∅, n → {5C}}}, 1D → {p → {5C}, x → 23}}
  • Object diagram representation:

1C : C p = ∅ 5C : C X 1D : D x = 23 n p

slide-38
SLIDE 38

Partial vs. Complete Object Diagrams

– 11 – 2017-06-26 – Sod –

39/51

  • By now we discussed “object diagram represents system state”:

{1C → {p → ∅, n → {5C}}, 5C → {p → ∅, n → ∅}, 1D → {p → {5C}, x → 23}}

  • 1C : C

p = ∅ 5C : C p = ∅ n = ∅ 1D : D x = 23 n p

What about the other way round...?

  • Object diagrams can be partial, e.g.

1C : C 5C : C 1D : D x = 23 n

  • r

1C : C 5C : C 1D : D

→ we may omit information.

  • Is the following object diagram partial or complete?

1C : C p = ∅ 5C : C p = ∅ n = ∅ 1D : D x = 23 n p

  • If an object diagram
  • has values for all attributes of all objects in the diagram, and
  • if we say that it is meant to be complete

then we can uniquely reconstruct a system state σ.

slide-39
SLIDE 39

Special Case: Anonymous Objects

– 11 – 2017-06-26 – Sod –

40/51

If the object diagram

1C : C p = ∅ : C p = ∅ n = ∅ : D x = 23 n p

is considered as complete, then it denotes the set of all system states {1C → {p → ∅, n → {c}}}, c → {p → ∅, n → ∅}, d → {p → {c}, x → 23}} where c ∈ D(C), d ∈ D(D), c = 1C. Intuition: different boxes represent different objects.

slide-40
SLIDE 40

Object Diagrams at Work

– 11 – 2017-06-26 – main –

41/51

slide-41
SLIDE 41

Example: Data Structure (Schumann et al., 2008)

– 11 – 2017-06-26 – Sodatwork –

42/51

BaseNode

parent : BaseNode∗ prevSibling : BaseNode∗ nextSibling : BaseNode∗ firstChild : BaseNode∗ lastChild : BaseNode∗

Node

data : T Node( data : T)

Iterator

  • perator++() : Iterator
  • perator−−() : Iterator
  • perator∗() : BaseNode0,1

Forest

appendTopLevel( data: T ) appendChild( parent : Iterator, data : T ) remove( it : Iterator ) depth( it : Iterator ) : int end() : Iterator begin() : Iterator empty() : bool size() : int

node begin_it end_it

slide-42
SLIDE 42

Example: Illustrative Object Diagram (Schumann et al., 2008)

– 11 – 2017-06-26 – Sodatwork –

43/51

: Iterator : Forest : Iterator A : Node E : Node end : BaseNode B : Node C : Node F : Node D : Node

begin_it end_it node node firstChild parent firstChild parent nextSib prevSib lastChild firstChild parent nextSib prevSib lastChild firstChild parent nextSib prevSib

BaseNode

parent : BaseNode∗ prevSibling : BaseNode∗ nextSibling : BaseNode∗ firstChild : BaseNode∗ lastChild : BaseNode∗

Node

data : T Node( data : T)

Iterator

  • perator++() : Iterator
  • perator−−() : Iterator
  • perator∗() : BaseNode0,1

Forest

appendTopLevel( data: T ) appendChild( parent : Iterator, data : T ) remove( it : Iterator ) depth( it : Iterator ) : int end() : Iterator begin() : Iterator empty() : bool size() : int

node begin_it end_it

slide-43
SLIDE 43

Object Diagrams for Analysis

– 11 – 2017-06-26 – Sodatwork –

44/51

: M ctime = 27 : N data = d1 : M ctime = 5 : N data = d2 : N data = d3 : N data = d4 : M ctime = 9 : N data = d5 | | | | |

slide-44
SLIDE 44

Content

– 11 – 2017-06-26 – Scontent –

45/51

  • Software Modelling
  • views & viewpoints
  • the 4+1 view
  • Class Diagrams
  • concrete syntax,
  • abstract syntax,
  • class diagrams at work,
  • semantics: system states.
  • Object Diagrams
  • concrete syntax,
  • dangling references,
  • partial vs. complete,
  • object diagrams at work.
  • Software Modelling Cont’d
  • An outlook on UML
  • model-driven software engineering
slide-45
SLIDE 45

Tell Them What You’ve Told Them. . .

– 11 – 2017-06-26 – Sttwytt –

49/51

  • Software Modelling: views and viewpoints, e.g. 4+1
  • Model-driven Software Engineering
  • Unified Modelling Language:
  • a family of modelling languages,
  • including languages to model structure and behaviour.
  • Class Diagrams can be used to graphically
  • visualise code,
  • define an object system structure S .
  • An Object System Structure S

(together with a structure D)

  • defines a set of system states ΣD

S .

  • A System State σ ∈ ΣD

S

  • can be visualised by an object diagram.
slide-46
SLIDE 46

References

– 11 – 2017-06-26 – main –

50/51

slide-47
SLIDE 47

References

– 11 – 2017-06-26 – main –

51/51

Ambler, S. W. (2005). The Elements of UML 2.0 Style. Cambridge University Press. Booch, G. (1993). Object-oriented Analysis and Design with Applications. Prentice-Hall. Dobing, B. and Parsons, J. (2006). How UML is used. Communications of the ACM, 49(5):109–114. Harel, D. (1987). Statecharts: A visual formalism for complex systems. Science of Computer Programming, 8(3):231–274. Harel, D. (1997). Some thoughts on statecharts, 13 years later. In Grumberg, O., editor, CAV, volume 1254 of LNCS, pages 226–231. Springer-Verlag. Harel, D., Lachover, H., et al. (1990). Statemate: A working environment for the development of complex reactive systems. IEEE Transactions on Software Engineering, 16(4):403–414. IEEE (2000). Recommended Practice for Architectural Description of Software-Intensive Systems. Std 1471. Jacobson, I., Christerson, M., and Jonsson, P. (1992). Object-Oriented Software Engineering - A Use Case Driven Approach. Addison-Wesley. Kopetz, H. (2011). What I learned from Brian. In Jones, C. B. et al., editors, Dependable and Historic Computing, volume 6875 of

  • LNCS. Springer.

Kruchten, P. (1995). The “4+1” view model of software architecture. IEEE Software, 12(6):42–50. Lovins, A. B. and Lovins, L. H. (2001). Brittle Power - Energy Strategy for National Security. Rocky Mountain Institute. Ludewig, J. and Lichter, H. (2013). Software Engineering. dpunkt.verlag, 3. edition. OMG (2006). Object Constraint Language, version 2.0. Technical Report formal/06-05-01. OMG (2007). Unified modeling language: Superstructure, version 2.1.2. Technical Report formal/07-11-02. Rumbaugh, J., Blaha, M., Premerlani, W., Eddy, F., and Lorensen, W. (1990). Object-Oriented Modeling and Design. Prentice Hall. 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.