02291: System Integration

Size: px
Start display at page:

Download "02291: System Integration"

Transcription

1 02291: System Integration Week 8 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018

2 Last Week Components: Synchronized communication Sequence Diagrams Use Case Realization

3 Contents Desgin by Contract and OCL Principles of Good Design

4 What does this function do? Implementation public List<Integer> f(list<integer> vector) { if (vector.size() <= 1) return vector; int k = vector.elementat(0); List<Integer> less = new List<Integer>(); List<Integer> equal = new List<Integer>(); List<Integer> bigger = new List<Integer>(); g(k,vector,less,equal,bigger); List<Integer> r = f(less); r.addall(equal); r.addall(f(bigger)); } return r; public void g(int k, List<Integer> vector, List<Integer> less, List<Integer> equal, List<Integer> bigger) { for (int i : vector) { if (i < k) less.add(i); if (i == k) equal.add(i); if (i > k) bigger.add(i); } }

5 Contract for the sort function in OCL Specification (Contract) in OCL context C::sort(a : Sequence(Integer)) : Sequence(Integer) pre: a <> null post: issorted(result) and sameelements(a,result) def: issorted(result) = Sequence {1..a.length}->forAll(i Sequence {1..a.length}->forAll( j i < j implies a->at(i) <= a->at(j)) def: sameelements(a1, a2 : Sequence(Integer)) = a1->forall( i a1->count(i) = a2->count(i)) and a2->forall( i a1->count(i) = a2->count(i))

6 Contracts {The field i should always be greater than 0.} i : int Counter inc() : void dec() : void {The operation dec should be called only if i is greater than zero. In this case i is decremented by one.} {The inc operation increases i by one.} public T n(t1 a1,.., Tn an, Counter c)... c.dec();... Contract for dec Method n ensures pre-condition c.i > 0 before calling c.dec() Method dec ensures counter is decremented, only when c.i > 0 Undefined what happens when c.i <= 0

7 Example {The field i should always be greater than 0.} i : int Counter inc() : void dec() : void {The operation dec should be called only if i is greater than zero. In this case i is decremented by one.} {The inc operation increases i by one.}

8 Example {The field i should always be greater than 0.} i : int Counter inc() : void dec() : void {The operation dec should be called only if i is greater than zero. In this case i is decremented by one.} {The inc operation increases i by one.} {context Counter :: dec ( ) pre: i > 0 post: i = i@pre - 1 } i : int Counter inc() : void dec() : void {context Counter inv: i >= 0} {context Counter :: inc ( ) post: i = i@pre + 1}

9 Object Constraint Language (OCL) Express constraints in UML diagrams in a formal way 1 Invariants of UML diagrams 2 The contract of operations (i.e. pre- and postconditions of operations) 3 body of query operations ( query ; don t change the state) query operations can be used in OCL constraints, but not state changing operations

10 Bank example with constraints Bank {context Bank inv: accounts->forall(a a.owner = self) owner 1 accounts 0..* Account bal : int update(n : int) : void {inv: bal >= 0} {pre: bal + n >= 0 post: bal = bal@pre + n and history.oclisnew() and history.bal = bal@pre and history.prev = history@pre} History 0..1 bal : int prev History() : void 1

11 Update operation of Account State before executing update(n) {n + b >= 0} a: Account bal = b bal = m h: History

12 Update operation of Account State before executing update(n) State after executing update(n) {n + b >= 0} a: Account bal = b + n a: Account bal = b h1: History bal = b bal = m h: History bal = m prev h: History

13 OCL Syntax More on OCL operators and OCL Online on Safari books: Object Constraint Language by Jos Warmer, Anneke Kleppe (cf. course home page)

14 OCL expressions and their evaluation OCL expression evaluated in a context. Class, Operation, Association,... Expression cannot change the state of the system can t call state changing operations (basically no method calls are allowed) Exception: calls to methods marked {query} are allowed No assignment operator (= means equality)

15 Type of constraints The type of the constraint Most common Invariant for classes (inv:) precondition for operations (pre:) postcondition for operations (post:) Others body: exp def: name(parameter:type) : type = expr Ex. def: initial : String = name.substring(1,1) Ex. def: gettotalpoints(d:date) : Integer = OCL expression

16 Notation Within notes in {} {pre: i > 0 post: i = i@pre -1} Counter i : int inc dec {inv: i >= 0} {post: i = i@pre + 1} As separate text. In this case the context part must be present context Counter inv: i >= 0 context Counter :: inc post: i = i@pre + 1

17 OCL Syntax (simplified): Available types Basic datatypes: Integer, Real, Boolean, String Boolean operators: =, <>, not, and, or, implies,..., x.isocltypeof (C) All classes C from the UML model Collection types: Set(C), OrderedSet(C), Bag(C), Sequence(C)

18 OCL Syntax (simplified): Basic operations y:int m() A a b x:int B Attribute / Navigation (in the context of class A) self self.b.x Operation Calls self.m(c1,, c n ) (Method call) self.b cop(...) (Call to a method on collections) context A inv: self.b.x->includes(3)

19 Navigation Navigation via dot (.) notation to roles and attributes y:int A a b x:int B a1:a {y = 10} b1:b {x = 5} a1.b = a1.b.x =

20 Navigation Navigation via dot (.) notation to roles and attributes y:int A a b x:int B {x = 3} b1:b {y = 10} a1:a {x = 5} b2:b a1.b = a1.b.x =

21 OCL Syntax (simplified): OCL Boolean Operators and Collections Boolean operators Equal (=), Not-Equal (<>) not, and, or, implies,... x.isocltypeof (C) is true if x is an object of type C or a subtype thereof Collections Collection(C): Abstract supertype Set(C) (not ordered, no duplicates) OrderedSet(C) (ordered, no duplicates) Bag(C) (not ordered, allowes duplicates) Sequence(C) (ordered, allowes duplicates)

22 OCL Syntax (simplified): Operations on collections I collection forall(x P[x]) corresponds to x collection : P[x] collection exists(x P[x]) corresponds to x collection : P[x] collection select(x P[x]) corresponds to {x collection P[x]} collection collect(x E[x]) corresponds to {E[x] x collection} self.employee collect(birthday) = self.employee.birthday P[x] and E[x] means that x occures in predicate P and expression E

23 OCL Syntax (simplified): Operations on collections II Sequence{1, 2, 3} includes(3) = true more: includesall(collection), excludes, isempty, union, intersection, count... compare with Sequence{1, 2, 3} including(5) = Sequence {1, 2, 3, 5 } Conversions between collections: asset, asbag, assequence,... C.allInstances() sequence at(i) (s at(1) is the first element)

24 Flattening Collections Federation 1 * Club * member * Person f.club.member = f.club->collect(member) = f.club->collectnested(member) =

25 OCL Syntax (simplified): Postconditions Additionally in postconditions: result x.oclisnew() xˆm() Message m was send to x e.g. observerˆupdate

26 Observer Pattern «Interface» Observer update(observable o, Object arg) * Observable changed : bool addobserver(observer o) haschanged() : bool setchanged() clearchanged() notifyobservers(object arg)

27 Observer Pattern «Interface» Observer update(observable o, Object arg) * Observable changed : bool addobserver(observer o) haschanged() : bool setchanged() clearchanged() notifyobservers(object arg) context Observable::setChanged() post: changed

28 Observer Pattern «Interface» Observer update(observable o, Object arg) * Observable changed : bool addobserver(observer o) haschanged() : bool setchanged() clearchanged() notifyobservers(object arg) context Observable::setChanged() post: changed context Observable::clearChanged() post: not(changed)

29 Observer Pattern «Interface» Observer update(observable o, Object arg) * Observable changed : bool addobserver(observer o) haschanged() : bool setchanged() clearchanged() notifyobservers(object arg) context Observable::setChanged() post: changed context Observable::clearChanged() post: not(changed) context Observable::hasChanged() post: result = changed

30 Observer Pattern «Interface» Observer update(observable o, Object arg) * Observable changed : bool addobserver(observer o) haschanged() : bool setchanged() clearchanged() notifyobservers(object arg) context Observable::setChanged() post: changed context Observable::clearChanged() post: not(changed) context Observable::hasChanged() post: result = changed context Observable::hasChanged() body: changed

31 Observer Pattern «Interface» Observer update(observable o, Object arg) * Observable changed : bool addobserver(observer o) haschanged() : bool setchanged() clearchanged() notifyobservers(object arg) context Observable::setChanged() post: changed context Observable::clearChanged() post: not(changed) context Observable::hasChanged() post: result = changed context Observable::addObservers(Observer o) post: observers = observers@pre->including(o) context Observable::hasChanged() body: changed

32 Observer Pattern «Interface» Observer update(observable o, Object arg) * Observable changed : bool addobserver(observer o) haschanged() : bool setchanged() clearchanged() notifyobservers(object arg) context Observable::setChanged() post: changed context Observable::clearChanged() post: not(changed) context Observable::hasChanged() post: result = changed context Observable::addObservers(Observer o) post: observers = observers@pre->including(o) context Observable::notifyObservers(Object arg) pre: changed post: observers->forall( o oˆupdate(self, arg)) and not(changed) context Observable::hasChanged() body: changed

33 Observer Pattern «Interface» Observer update(observable o, Object arg) * Observable changed : bool addobserver(observer o) haschanged() : bool setchanged() clearchanged() notifyobservers(object arg) context Observable::setChanged() post: changed context Observable::clearChanged() post: not(changed) context Observable::hasChanged() post: result = changed context Observable::addObservers(Observer o) post: observers = observers@pre->including(o) context Observable::notifyObservers(Object arg) pre: changed post: observers->forall( o oˆupdate(self, arg)) and not(changed) context Observable::hasChanged() body: changed context Observable::notifyObservers(Object arg) post: changed@pre implies (observers->forall( o oˆupdate(self, arg)) and not(changed))

34 Observer Pattern Final «Interface» Observer update(observable o, Object arg) * Observable changed : bool addobserver(observer o) notifyobservers(object arg) context Observable::addObservers(Observer o) post: observers = observers@pre->including(o) context Observable::notifyObservers(Object arg) post: changed@pre implies (observers->forall( o oˆupdate(self, arg)) and not(changed))

35 Example Vending Machine

36 Vending machine behaviour with OCL constraints {inv: currentmoney >= 0 and totalmoney >= 0 and restmoney >= 0 } {pre: m > 0 post: if (selectedfruit <> null and enoughmoney(selectedfruit)) then itemdispensed(f,currentmoney@pre + m) else currentmoney = currentmoney@pre + m endif } {post: if enoughmoney(f) then itemdispensed(f,currentmoney@pre) else selectedfruit = f endif } {post: currentmoney = 0 and restmoney = currentmoney@pre and selectedfruit->size() = 0 } {def: itemdispensed(f:fruit, oldcm:int) = dispenseditem = f and restmoney = oldcm - pricefor(f) and currentmoney = 0 and totalmoney = totalmoney + pricefor(f) } VendingMachine fruit «enumeration» * currentmoney: int Fruit totalmoney: int dispenseditem 0..1 banana restmoney: int selectedfruit 0..1 apple input(m:int) select(f:fruit) {body: currentmoney >= pricefor(f)} cancel() enoughmoney(f:fruit) {isquery} hasfruit(f:fruit) {isquery} {body: fruit->collect(f1 f1 = f)->size() >= 1} dispense(f:fruit) pricefor(f:fruit) {isquery} {pre: enoughmoney(f) and hasfruit(f) post: itemdispensed(f,currentmoney@pre) } {pre: (f = banana) or (f = apple) body: if (f = banana) then 5 else 3 }

37 Vending machine behaviour as life cycle state machine

38 Contents Desgin by Contract and OCL Principles of Good Design

39 DRY principle DRY principle Don t repeat yourself Every piece of knowledge must have a single, unambiguous, authoritative representation within a system. The Pragmatic Programmer, Andrew Hunt and David Thomas code documentation build stystem

40 Example: Code Duplication

41 Example: Code Duplication Person name cpr-number home-address-street home-address-city printaddress Person name cpr-number home address Address street city printaddress address works at Company name c-address-street c-address-city printaddress works at name Company

42 DRY principle Techniques to avoid duplication Use appropriate abstractions Delegation Inheritance Classes with instance variables Methods with parameters Refactor to remove duplication Generate artefacts from a common source. Eg. Javadoc

43 KISS principle KISS principle Keep it short and simple (sometimes also: Keep it simple, stupid) simplest solution first Strive for simplicity Takes time!! refactor for simplicity Antoine de Saint Exupéry It seems that perfection is reached not when there is nothing left to add, but when there is nothing left to take away.

44 YAGNI principle YAGNI principle You ain t gonna needed it Focus on the task at hand E.g. using the observer pattern because it might be needed Two different kinds of flexibility make your design changeable tests, easy to refactor design for change Use good OO principles High cohesion, low coupling Decentralized control Both are needed, but focus on the first before introducing not needed constructs for the second

45 Low Coupling High coupling A B C D E F

46 Low Coupling High coupling A B C D E F Low coupling A C B E D F

47 High Cohesion Low Cohesion Person name cpr-number companyname work-address-street work-address-city home-address-street home-address-city

48 High Cohesion Low Cohesion Person name cpr-number companyname work-address-street work-address-city home-address-street home-address-city High Cohesion Person name cpr-number home address street city Address address works at name Company

49 Law of Demeter Law of Demeter Only talk to your immediate friends Only method calls to the following objects are allowed the object itself its components objects created by that object parameters of methods Law of Demeter = low coupling delegate functionality decentralised control

50 Computing the price of an order Order calculate price calculate base price calculate discounts 1 Customer name discount info quantity * OrderLine 1 name price Product

51 Computing the price of an order Order calculate price calculate base price calculate discounts 1 Customer name discount info calculate discount * OrderLine quantity calculate price 1 Product name price get price for quantity

52 Layered Architecture Eric Evans, Domain Driven Design, Addison-Wesley, 2004

53 Example Vending Machine Two different presentation layers Swing GUI Command line interface Current Money: DKK 5 0) Exit 1) Input 1 DKK 2) Input 2 DKK 3) Input 5 DKK 4) Select banana 5) Select apple 6) Cancel Select a number (0-6): Rest: DKK 2 Current Money: DKK 0 Dispensing: Apple

54 Architecture Presentation Layer Presentation Layer VendingMachineUI «delegate» VendingMachineTextUI «delegate» Observer Observer Application Layer Observable «delegate» VendingMachine dispenseditem : Fruit currentmoney : int totalmoney : int restmoney : int input(money : int) select(f : fruit) cancel() «enumeration» Fruit APPLE BANANA

55 Presentation Layer: Swing GUI sd:buy apple

56 Presentation Layer: Command Line Interface sd:buy apple

57 Advantages of the separation 1 Presentation layer easily changed 2 Additional presentation layers 3 Automatic tests under the GUI

58 Buy Fruit Fit tests Main Scenario ActionFixture start VendingMachineFixture check number of apples 5 enter input 1 enter input 2 press apple check dispensed item apple check rest money 0 check number of apples 4 Alternative Scenario a ActionFixture start VendingMachineFixture check number of apples 5 enter input 1 enter input 5 press apple check dispensed item apple check rest money 3 check number of apples 4 Use Case Buy Fruit main scenario: 1. Input coins until the price for the fruit to be selected is reached 2. Select a fruit 3. Vending machine dispenses fruit alternative scnearios: a1. User inputs more coins than necessary a2. select a fruit a3. Vending machine dispenses fruit a4. Vending machine returns excessive coins

59 Project Goal: Create a model Domain model Requirements model Test model Design model Class diagram Component diagram Behaviour diagrams Use case validation, i.e., use case realization Teams with 6 people Teams are formed next time Make sure you, or someone who can speak for you, is at the lecture next time to sign up the team. If not, there won t be any guarantees for being able to join a team

02291: System Integration

02291: System Integration 02291: System Integration Hubert Baumeister hub@imm.dtu.dk Spring 2011 Contents 1 Recap 1 2 More UML Diagrams 2 2.1 Object Diagrams........................................... 2 2.2 Communication Diagrams......................................

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 10 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2016 Last Time Project Planning Non-agile Agile Refactoring Contents Basic Principles

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 11 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2017 Recap I Software Development Processes (cont.) I Project Planning I Design

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 9: Principles of good design, Patterns, Layered Architecture Hubert Baumeister Informatics and Mathematical Modelling Technical University of Denmark Spring 2010 c 2010

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 8 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2018 Contents Basic Principles of Good Design Design Patterns Low Coupling High coupling

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 4 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2016 Recap Test in general validation and defect test unit-, component-, system-,

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 6 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2016 Contents Sequence Diagrams II Object-orientation: Centralized vs Decentralized

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 1 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2013 Contents Course Introduction Introduction to Software Engineering Practical

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 8: Principle of good Design, Project, and Design Patterns Hubert Baumeister Informatics and Mathematical Modelling Technical University of Denmark Spring 2009 c 2009

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 10 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2017 Last Week Layered Architecture: Persistent Layer Software Development Processes

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 1 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2016 Contents Course Introduction Introduction to Software Engineering Practical

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 9 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2018 Recap Last week Principles of good design: DRY, KISS, YAGNI, high cohesion /

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 1 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2017 Contents Course Introduction Introduction to Software Engineering Practical

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 5 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2015 Contents From Requirements to Design: CRC Cards Class Diagrams I Sequence Diagrams

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 8 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2017 Recap I Last week I Sequence diagrams I Centralized vs. Decentralized Control

More information

Index. business modeling syntax 181 business process modeling 57 business rule 40

Index. business modeling syntax 181 business process modeling 57 business rule 40 OCL.book Page 203 Tuesday, July 22, 2003 9:48 PM Index Symbols OclAny, of 167 = OclAny, of 167 @pre 34, 86, 155 ^ 34, 156 ^^ 157 A abstract syntax 93 accumulator 153 action in statechart 56 activity

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 6: Design 1: CRC cards, class and sequence diagram Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2017 Contents Midterm evaluation

More information

02291: System Integration

02291: System Integration 02291: System Integration Week 4 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018 Contents From Requirements to Design CRC Cards Components (part Ia) Object-orientation:

More information

Architectural Models and Styles Component-Based Software Engineering ECE493-Topic 5 Winter 2007 Lecture 12 The Object Constraint Language (Part A)

Architectural Models and Styles Component-Based Software Engineering ECE493-Topic 5 Winter 2007 Lecture 12 The Object Constraint Language (Part A) Component-Based Software Engineering ECE493-Topic 5 Winter 2007 Lecture 12 The Object Constraint Language (Part A) Ladan Tahvildari Assistant Professor Dept. of Elect. & Comp. Eng. University of Waterloo

More information

OCL and Concept Model

OCL and Concept Model OCL and Concept Model Jörg Kienzle & Alfred Strohmeier COMP-533 OCL and Concept Model OCL History and Goal Constraints OCL Types Base Types & Operations Collection Types & Operations Navigating UML Diagrams

More information

02291: System Integration

02291: System Integration 02291: System Integration Week 7 Hubert Baumeister hub@imm.dtu.dk DTU Compute Technical University of Denmark Spring 2016 Contents Components (part III) Sequence Diagrams Design Validation: Use Case Realization

More information

Hans Karlsen. MDriven The book. Doing effective Business by taking control of Information. Hans Karlsen, Stockholm, Sweden

Hans Karlsen. MDriven The book. Doing effective Business by taking control of Information. Hans Karlsen, Stockholm, Sweden Hans Karlsen MDriven The book Doing effective Business by taking control of Information Hans Karlsen, Stockholm, Sweden 2016-01-23 Part 8 Object Constraint Language 1 What is Object Constraint Language

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 7 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2016 Contents State machines Library Application and GUI Layered Architecture: Persistence

More information

02291: System Integration

02291: System Integration 02291: System Integration Week 5 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2017 Contents Object-orientation: Centralized vs Decentralized Control/Computation Class

More information

02291: System Integration

02291: System Integration 02291: System Integration Week 10 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018 Last Week Principles of good design: layered architecture Software Development Processes

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 7 Assoc. Prof. Hubert Baumeister Informatics and Mathematical Modelling Technical University of Denmark Spring 2011 c 2011 H. Baumeister (IMM) Software Engineering I

More information

Specification with OCL

Specification with OCL Specification with OCL Jurriaan Hage Slides adapted from Birgit Demuth, TU Dresden e-mail: jur@cs.uu.nl homepage: http://www.cs.uu.nl/people/jur/ Department of Information and Computing Sciences, Universiteit

More information

Rubby Casallas Grupo de Construcción de Software Uniandes

Rubby Casallas Grupo de Construcción de Software Uniandes UML OCL 2.0 Rubby Casallas Grupo de Construcción de Software Uniandes Why OCL? A UML diagram, such as a class diagram, is typically not refined enough to provide all the relevant aspects of a specification.

More information

02291: System Integration

02291: System Integration 02291: System Integration Week 5 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018 Contents Components (part Ia) Class Diagrams Important Concepts Class Diagrams Software

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 2: Class diagrams part 1 Hubert Baumeister Informatics and Mathematical Modelling Technical University of Denmark Spring 2010 c 2010 H. Baumeister (IMM) Software Engineering

More information

Chapter 8, Object Design: Object Constraint Language

Chapter 8, Object Design: Object Constraint Language Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 8, Object Design: Object Constraint Language Outline of the Lecture OCL Simple predicates Preconditions Postconditions Contracts

More information

What is OCL? OCL/Context

What is OCL? OCL/Context What is? Software Engineering Lecture 5: Prof. Dr. Peter Thiemann Universität Freiburg SS 20 = object constraint language standard query language of UML 2 specify expressions and constraints in object-oriented

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 7 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2018 Contents Sequence Diagrams Object-orientation: Centralized vs Decentralized

More information

Software Engineering

Software Engineering Software Engineering Lecture 15: OCL Peter Thiemann University of Freiburg, Germany 01.07.2013 Peter Thiemann (Univ. Freiburg) Software Engineering 01.07.2013 1 / 28 What is OCL? OCL = Object Constraint

More information

Agenda. More on the Unified Modeling Language. UML diagram types. Packages

Agenda. More on the Unified Modeling Language. UML diagram types. Packages Agenda More on the Unified Modeling Language Perdita Stevens, University of Edinburgh July 2010 And the rest... deployment diagrams, component diagrams, object diagrams, timing diagrams, etc. OCL and alternatives

More information

JML OCL. Java. iterate

JML OCL. Java. iterate 1 OCL JML OCL (Object Constraint Language) JML (Java Modelling Language) UML/OCL JML Java OCL JML iterate iterate Java OCL JML The paper presents a translation method from OCL (Object Constraint Language)

More information

Formal Methods for Software Engineers

Formal Methods for Software Engineers Formal Methods for Software Engineers Professor Ray Welland Department of Computing Science University of Glasgow ray@dcs.gla.ac.uk INF3120-FM 1 Overview Motivation Why have formal specifications? Where

More information

ENGLISH Page 1 of 6. EXAM IN COURSE TDT4100 Object-Oriented Programming / IT1104 Programming, Advanced Course. Tuesday 29. Mai

ENGLISH Page 1 of 6. EXAM IN COURSE TDT4100 Object-Oriented Programming / IT1104 Programming, Advanced Course. Tuesday 29. Mai ENGLISH Page 1 of 6 NTNU Norges teknisk-naturvitenskapelige universitet Fakultet for informasjonsteknologi, matematikk og elektroteknikk Institutt for datateknikk og informasjonsvitenskap EXAM IN COURSE

More information

Specification-based Testing of Embedded Systems H. Schlingloff, SEFM 2008

Specification-based Testing of Embedded Systems H. Schlingloff, SEFM 2008 SEFM School 2008 Specification-based Testing of Embedded Systems Prof. Dr. Holger Schlingloff Humboldt-Universität zu Berlin and Fraunhofer FIRST, Berlin Lecture 5: OCL, ParTeG Course Outline L1: Introduction

More information

Formal Methods in Software Engineering 1

Formal Methods in Software Engineering 1 Today s Agenda Quiz 1 on next Tue. Quick Review Finish Program Proof Introduction to OCL Formal Methods in Software Engineering 1 Quick Review What is the difference between first-order logic and propositional

More information

02291: System Integration

02291: System Integration 02291: System Integration Week 6 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018 Contents UML State Machines Components (part II) UML Behaviour Diagrams Activity Diagrams

More information

CSC Advanced Object Oriented Programming, Spring Specification

CSC Advanced Object Oriented Programming, Spring Specification CSC 520 - Advanced Object Oriented Programming, Spring 2018 Specification Specification A specification is an unambiguous description of the way the components of the software system should be used and

More information

Advanced Class Diagrams and Intro to Interaction Modeling

Advanced Class Diagrams and Intro to Interaction Modeling Advanced Class Diagrams and Intro to Interaction Modeling Or: Advance to Illinois Avenue. Do not pass Go. Jonathan Sprinkle 1 University of Arizona Department of Electrical and Computer Engineering PO

More information

Object Constraint https://www.lri.fr/~linaye/gl.html lina.ye@centralesupelec.fr Sequence 3, 2017-2018 1/45 Plan 1 2 3 4 2/45 Motivation Why OCL Cannot represent all the relevant aspects of a specification

More information

02291: System Integration

02291: System Integration 02291: System Integration Week 7 Hubert Baumeister hub@imm.dtu.dk DTU Compute Technical University of Denmark Spring 2013 Contents Sequence Diagrams Design Validation: Use Case Realization Example: Interaction

More information

Specification-based Testing of Embedded Systems H. Schlingloff, SEFM 2008

Specification-based Testing of Embedded Systems H. Schlingloff, SEFM 2008 SEFM School 2008 Specification-based Testing of Embedded Systems Prof. Dr. Holger Schlingloff Humboldt-Universität zu Berlin and Fraunhofer FIRST, Berlin Lecture 4: Mutations, OCL etc. Course Outline L1:

More information

Software Development

Software Development Software Development and Professional Practice Object-Oriented Design Part the Third: (in which we revisit several parts of the OOA&D process, culminating in some general design principles) Object Oriented

More information

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17 List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code

More information

UNIT-II Introduction to UML

UNIT-II Introduction to UML UNIT-II Introduction to UML - P. P. Mahale UML OVERVIEW OF UML :- We need a Modeling Language! We will use the Unified Modeling Language, UML), Provides a standard for artifacts produced during development

More information

OCL parsing / type checking in the context of GF and KeY. Kristofer Johannisson

OCL parsing / type checking in the context of GF and KeY. Kristofer Johannisson OCL parsing / type checking in the context of GF and KeY Kristofer Johannisson 1 I. Introduction 2 Typechecking? context OwnerPIN inv: maxpinsize > 0 and maxtries > 0 and triesremaining >= 0 and triesremaining

More information

CIS 771: Software Specifications. Lecture 14: Advanced OCL Expressions

CIS 771: Software Specifications. Lecture 14: Advanced OCL Expressions CIS 771: Software Specifications Lecture 14: Advanced OCL Expressions Copyright 2001-2002, Matt Dwyer, John Hatcliff, and Rod Howell. The syllabus and all lectures for this course are copyrighted materials

More information

Component-Based Software Engineering

Component-Based Software Engineering Component-Based Software Engineering ECE493-Topic 5 Winter 2007 Lecture 14 The Object Constraint Language (Part C) Ladan Tahvildari Assistant Professor Dept. of Elect. & Comp. Eng. University of Waterloo

More information

The Object Constraint Language (OCL)

The Object Constraint Language (OCL) The Object Constraint Language (OCL) Robert B. France Dept. of Computer Science Colorado State University USA france@cs.colostate.edu Semantics and UML models UML models often treated as informal descriptions

More information

(The obligatory second slide)

(The obligatory second slide) Agile MDA: Naked Objects & Together Control Center Dan Haywood Haywood Associates Ltd. (The obligatory second slide) I'm an independent consultant / developer / trainer Java, J2EE,.Net, RDBMS, OO, UML,

More information

IT 313 Advanced Application Development

IT 313 Advanced Application Development Page 1 of 10 IT 313 Advanced Application Development Final Exam -- March 13, 2016 Part A. Multiple Choice Questions. Answer all questions. You may supply a reason or show work for partial credit. 5 points

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 3 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2013 Recap Requirements Engineering user- / system requirements functional- / non-functional

More information

Software Specifications. CMSC 433 Programming Language Technologies and Paradigms Spring Specifications Help You Write Code

Software Specifications. CMSC 433 Programming Language Technologies and Paradigms Spring Specifications Help You Write Code Software Specifications CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Documentation Feb. 20, 2007 A specification defines the behavior of an abstraction This is the contract between

More information

The Object Contraint Language by Example

The Object Contraint Language by Example Formal Specification of Software The Object Contraint Language by Example Bernhard Beckert UNIVERSITÄT KOBLENZ-LANDAU B. Beckert: Formal Specification of Software p.1 The Classifier Context inv ( c :)?

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 5 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2018 Contents User Stories Class Diagrams I Version control User stories Requirements

More information

OO Design Principles

OO Design Principles OO Design Principles Software Architecture VO (706.706) Roman Kern Institute for Interactive Systems and Data Science, TU Graz 2018-10-10 Roman Kern (ISDS, TU Graz) OO Design Principles 2018-10-10 1 /

More information

Appendix A OCL 2.0 Grammar

Appendix A OCL 2.0 Grammar Appendix A OCL 2.0 Grammar In this appendix we summarise the concrete syntax of OCL [113] using an extended Backus-Naur format [8]. The grammar in [113] is different from the grammar presented here. It

More information

An Introduction to Subtyping

An Introduction to Subtyping An Introduction to Subtyping Type systems are to me the most interesting aspect of modern programming languages. Subtyping is an important notion that is helpful for describing and reasoning about type

More information

Unified Modeling Language 2

Unified Modeling Language 2 Unified Modeling Language 2 Profiles 166 Usage scenarios Metamodel customization for adapting terminology to a specific platform or domain adding (visual) notation adding and specializing semantics adding

More information

SLIDES: Introductory Modeling Example Employing UML and OCL [UML: Unified Modeling Language, OCL:Object Constarint Language]

SLIDES: Introductory Modeling Example Employing UML and OCL [UML: Unified Modeling Language, OCL:Object Constarint Language] Lecture day 2016-04-07 SLIDES: Introductory Modeling Example Employing UML and OCL [UML: Unified Modeling Language, OCL:Object Constarint Language] - System design in an object-oriented way employing USE

More information

Software Engineering with Objects and Components Open Issues and Course Summary

Software Engineering with Objects and Components Open Issues and Course Summary Software Engineering with Objects and Components Open Issues and Course Summary Massimo Felici Software Engineering with Objects and Components Software development process Lifecycle models and main stages

More information

Specifications. CSE 331 Spring 2010

Specifications. CSE 331 Spring 2010 Specifications CSE 331 Spring 2010 The challenge of scaling software Small programs are simple and malleable easy to write easy to change Big programs are (often) complex and inflexible hard to write hard

More information

Modelling with OCL. Context of OCL Expressions. The Object Constraint Language (OCL) Component-Based Software Engineering. ECE493-Topic 4 Winter 2006

Modelling with OCL. Context of OCL Expressions. The Object Constraint Language (OCL) Component-Based Software Engineering. ECE493-Topic 4 Winter 2006 Component-Based Software Engineering ECE493-Topic 4 Winter 2006 Lecture 10 The Object Constraint Language (Part B) Ladan Tahvildari Assistant Professor Dept. of Elect. & Comp. Eng. University of Waterloo

More information

Good Luck! CSC207, Fall 2012: Quiz 3 Duration 25 minutes Aids allowed: none. Student Number: Lecture Section: L0101. Instructor: Horton

Good Luck! CSC207, Fall 2012: Quiz 3 Duration 25 minutes Aids allowed: none. Student Number: Lecture Section: L0101. Instructor: Horton CSC207, Fall 2012: Quiz 3 Duration 25 minutes Aids allowed: none Student Number: Last Name: Lecture Section: L0101 First Name: Instructor: Horton Please fill out the identification section above as well

More information

Lecture 7: Data Abstractions

Lecture 7: Data Abstractions Lecture 7: Data Abstractions Abstract Data Types Data Abstractions How to define them Implementation issues Abstraction functions and invariants Adequacy (and some requirements analysis) Towards Object

More information

Lecture 3: Recursion; Structural Induction

Lecture 3: Recursion; Structural Induction 15-150 Lecture 3: Recursion; Structural Induction Lecture by Dan Licata January 24, 2012 Today, we are going to talk about one of the most important ideas in functional programming, structural recursion

More information

University of Swaziland Department Of Computer Science Supplementary Examination JULY 2012

University of Swaziland Department Of Computer Science Supplementary Examination JULY 2012 University of Swaziland Department Of Computer Science Supplementary Examination JULY 2012 Title ofpaper: Course number: Time Allowed: Cunder Unix CS344 Three (3) hours Instructions: Answer question 1.

More information

02291: System Integration

02291: System Integration 02291: System Integration Hubert Baumeister hub@imm.dtu.dk Spring 2012 Contents 1 General Information 1 2 Overview 3 3 Introduction to UML 11 4 Summary 16 1 General Information System Integration Type

More information

Today's Agenda. References. Open Closed Principle. CS 247: Software Engineering Principles. Object-Oriented Design Principles

Today's Agenda. References. Open Closed Principle. CS 247: Software Engineering Principles. Object-Oriented Design Principles CS 247: Software Engineering Principles Reading: none Object-Oriented Design Principles Today's Agenda Object-Oriented Design Principles - characteristics, properties, and advice for making decisions that

More information

Object Oriented Program Correctness with OOSimL

Object Oriented Program Correctness with OOSimL Kennesaw State University DigitalCommons@Kennesaw State University Faculty Publications 12-2009 Object Oriented Program Correctness with OOSimL José M. Garrido Kennesaw State University, jgarrido@kennesaw.edu

More information

MSO Lecture Design by Contract"

MSO Lecture Design by Contract 1 MSO Lecture Design by Contract" Wouter Swierstra (adapted by HP, AL) October 8, 2018 2 MSO SO FAR Recap Abstract Classes UP & Requirements Analysis & UML OO & GRASP principles Design Patterns (Facade,

More information

Lecture 03: Object Constraint Language

Lecture 03: Object Constraint Language Software Design, Modelling and Analysis in UML Lecture 03: Object Constraint Language 2016-10-27 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universität Freiburg, Germany 03 2016-10-27

More information

Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of

Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of Computer Science Technische Universität Darmstadt Dr.

More information

Course "UML and Design Patterns" of module "Software Engineering and Design", version February 2011 (X)

Course UML and Design Patterns of module Software Engineering and Design, version February 2011 (X) UML Class Diagrams Prof. Dr. Eric Dubuis, @ Biel Course "UML and Design Patterns" of module "Software Engineering and Design", version February 2011 (X) BFH/TI/Software Engineering and Design/UML and Design

More information

Software Design, Modelling and Analysis in UML

Software Design, Modelling and Analysis in UML Software Design, Modelling and Analysis in UML Lecture 03: Object Constraint Language (OCL) 2013-10-28 03 2013-10-28 main Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universität Freiburg,

More information

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107 A abbreviations 17 abstract class 105 abstract data types 105 abstract method 105 abstract types 105 abstraction 92, 105 access level 37 package 114 private 115 protected 115 public 115 accessors 24, 105

More information

CSE 70 Final Exam Fall 2009

CSE 70 Final Exam Fall 2009 Signature cs70f Name Student ID CSE 70 Final Exam Fall 2009 Page 1 (10 points) Page 2 (16 points) Page 3 (22 points) Page 4 (13 points) Page 5 (15 points) Page 6 (20 points) Page 7 (9 points) Page 8 (15

More information

Génie Logiciel Avancé

Génie Logiciel Avancé L3 Mention Informatique Parcours Informatique et MIAGE Génie Logiciel Avancé UML/MOAL II Burkhart Wolff wolff@lri.fr Plan of the Chapter $ Semantics of MOAL Constraints % Class Invariants % Pre- and Post-Conditions

More information

Software Design, Modelling and Analysis in UML

Software Design, Modelling and Analysis in UML Software Design, Modelling and Analysis in UML Lecture 03: Object Constraint Language (OCL) 2013-10-28 03 2013-10-28 main Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universität Freiburg,

More information

Computer Science 2 Lecture 4 Inheritance: Trinidad Fruit Stand 02/15/2014 Revision : 1.7

Computer Science 2 Lecture 4 Inheritance: Trinidad Fruit Stand 02/15/2014 Revision : 1.7 Computer Science 2 Lecture 4 Inheritance: Trinidad Fruit Stand 02/15/2014 Revision : 1.7 1 Problem Ralph owns the Trinidad Fruit Stand that sells its fruit on the street, and he wants to use a computer

More information

CIS 120 Midterm I February 16, 2015 SOLUTIONS

CIS 120 Midterm I February 16, 2015 SOLUTIONS CIS 120 Midterm I February 16, 2015 SOLUTIONS 1 1. Substitution semantics (18 points) Circle the final result of simplifying the following OCaml expressions, or Infinite loop if there is no final answer.

More information

Testing, Debugging, and Verification

Testing, Debugging, and Verification Testing, Debugging, and Verification Formal Specification, Part II Srinivas Pinisetty 23 November 2017 Introduction Today: Introduction to Dafny: An imperative language with integrated support for formal

More information

CONSTRAINT SPECIFICATIONS USING PATTERNS IN OCL

CONSTRAINT SPECIFICATIONS USING PATTERNS IN OCL CONSTRAINT SPECIFICATIONS USING PATTERNS IN OCL Ali Hamie. University of Brighton, Brighton, UK a.a.hamie@brighton.ac.uk ABSTRACT Constraint patterns are very useful for specifying OCL constraints on UML

More information

Lecture 9. UML language architecture

Lecture 9. UML language architecture Lecture 9 UML Model architecture Object Constraint Language 12/10/98 AOO / UML / OCL/Strategies 1 UML language architecture UML metamodel defines meaning of UML models Defined in a metacircular manner,

More information

How to Design Programs

How to Design Programs How to Design Programs How to (in Racket): represent data variants trees and lists write functions that process the data See also http://www.htdp.org/ 1 Running Example: GUIs Pick a fruit: Apple Banana

More information

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1 Natural Semantics Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1 1 Natural deduction is an instance of first-order logic; that is, it is the formal

More information

OCL Support in MOF Repositories

OCL Support in MOF Repositories OCL Support in MOF Repositories Joachim Hoessler, Michael Soden Department of Computer Science Technical University Berlin hoessler@cs.tu-berlin.de, soden@cs.tu-berlin.de Abstract From metamodels that

More information

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT. Object Oriented Programming

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT. Object Oriented Programming BCS THE CHARTERED INSTITUTE FOR IT BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT Object Oriented Programming Examiner s Report March 2017 A1. a) Explain what is meant by the following terms:

More information

Formal Methods in Software Engineering 1

Formal Methods in Software Engineering 1 Building Models with OCL Introduction Completing UML Diagrams Modeling Tips and Hints Summary Formal Methods in Software Engineering 1 What Is a Model? Simply put, a model is a high level system description.

More information

The following topics will be covered in this course (not necessarily in this order).

The following topics will be covered in this course (not necessarily in this order). The following topics will be covered in this course (not necessarily in this order). Introduction The course focuses on systematic design of larger object-oriented programs. We will introduce the appropriate

More information

CSE 331 Final Exam 12/9/13

CSE 331 Final Exam 12/9/13 Name There are 10 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes, closed

More information

are most specifically concerned with

are most specifically concerned with Observer Behavioral Patterns Behavioral patterns are those patterns that are most specifically concerned with communication between objects Introduction Name Observer Also Known As Dependents, Publish-Subscribe

More information

OCL Object Constraint Language

OCL Object Constraint Language PA103 - Object-oriented Methods for Design of Information Systems OCL Object Constraint Language Radek Ošlejšek Fakulta informatiky MU oslejsek@fi.muni.cz Literature The Object Constraint Language (Second

More information

Software Design, Modelling and Analysis in UML

Software Design, Modelling and Analysis in UML Software Design, Modelling and Analysis in UML Lecture 03: Object Constraint Language (OCL) 2012-10-30 03 2012-10-30 main Prof. Dr. Andreas Podelski, Dr. Bernd Westphal Albert-Ludwigs-Universität Freiburg,

More information

From OCL to Typed First-order Logic

From OCL to Typed First-order Logic 22c181: Formal Methods in Software Engineering The University of Iowa Spring 2008 From OCL to Typed First-order Logic Copyright 2007-8 Reiner Hähnle and Cesare Tinelli. Notes originally developed by Reiner

More information

02291: System Integration

02291: System Integration 02291: System Integration Week 3 Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2018 Contents User Stories Activity Diagrams Acceptance Tests User stories Basic requirements

More information