50
2IS55 Software Evolution Architecture Evolution Alexander Serebrenik

Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

2IS55 Software Evolution

ArchitectureEvolutionAlexander Serebrenik

Page 2: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Assignments: Reminder

• Assignment 2:• Deadline: Today!• Individual

• Assignment 3:• Deadline: March 16, 23:59• Individual or pair• Architecture reconstruction with

/ SET / W&I PAGE 125-2-2011

Sphinx 4.1 beta release 2 and 4

Page 3: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Sources

/ SET / W&I PAGE 225-2-2011

Page 4: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Part 1: Where are we now?

• Last week: architecture• Structure (class and package diagrams)

• This week: behaviour• Sequence diagrams• State diagrams (State machines)

/ SET / W&I PAGE 325-2-2011

Page 5: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Static vs. Dynamic Analysis

• Dynamic (execution)+ More precise- Requires the system to be executable- Limited to test-cases

• Static (no execution required)- Less precise (approximate but conservative)+ The system may be incomplete+ All possible executions can be considered

/ SET / W&I PAGE 425-2-2011

Object of the analysisStructure Behaviour

Analysis technique

Static Last week TodayDynamic

Page 6: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Static analysis of behavioural models

/ SET / W&I PAGE 525-2-2011

• Columns• Containers• Objects vs. classes

• Method invocations• Resolving the calls• Invocation order

Library1: Library Loan1: LoanInternalUser1:InternalUser, User1: User

Book1: Book, TR1:TR,

Journal1:JournalgetUser

addLoangetDocument

addLoan

Page 7: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Recapitulation: Object Flow Graph

• Vertices: variables, • x = y

• x = y.m(a1, …, ak)• Method m(f1, …, fk)

• x = new c(a1, …, ak)• cs – constructor of c

/ SET / W&I PAGE 625-2-2011

y x

y m.this

a1 f1 ak fk…

m.return x

a1 f1 ak fk…

cs.this x

fields, method parameters

Page 8: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

class BT {BTNode root;public void build() {

root = new BTNode();BTNode curNode = root;while(…) {

…curNode.addLeft(new BTNode());…curNode.addRight(new BTNode());

}}

}

Objects vs. Classes

/ SET / W&I PAGE 725-2-2011

class BTNode {BTNode left, right;public void addLeft(BTNode n) {

left = n; }public void addRight(BTNode n) {

right = n; }

}

132

1

2

3 Tonella, Potrich 2005

BTN.BTN.this

BTN.addLeft.n

BTN.left

BTN.addRight.n

BTN.right

BT.root

BTN.build.curNode

BTN.addLeft.this

BTN.addRight.this

Page 9: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Solution

/ SET / W&I PAGE 825-2-2011

gen(BT.root) = {BTN1}

gen(BTNode.add-Right.n) = {BTN3}

gen(BTN.add-Left.n) = {BTN2}

• Generate• Increment the counter for every “new BTNode”

• Propagate this information through the OFG

out(BTN.left) = {BTN2}

out(BT.root) = {BTN1}

out(BTN.left) = {BTN3}

/ SET / W&I PAGE 825-2-2011

BTN.BTN.this

BTN.addLeft.n

BTN.left

BTN.addRight.n

BTN.right

BT.root

BTN.build.curNode

BTN.addLeft.this

BTN.addRight.this

12 3

Page 10: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Objects vs. Classes

• We can use the same technique for sequence diagrams!

/ SET / W&I PAGE 925-2-2011

Tonella, Potrich 2005

BinaryTree

BTN

root

left, right

BinaryTree1

BTN3BTN2

BTN1

root

left right

left rightleft

right

Page 11: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Next step: resolving method calls

• Intuitively, C.m() ⇒ D

• In the OFG notation:• If D is a field: C.m.this ⇒ C.D• Otherwise: C.m.this ⇒ C.m.D

/ SET / W&I PAGE 1025-2-2011

class C {public m() {

D.n()}

}

• But these are classes, not objects! And containers…• If D is a field: out(C.m.this) ⇒ out(C.D)• Otherwise: out(C.m.this) ⇒ out(C.m.D)

• NB: out are sets (polymorphism)

Page 12: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Out is a set!

/ SET / W&I PAGE 1125-2-2011

Library1: Library Loan1: Loan

InternalUser1:InternalUser, User1:

User

Book1: Book, TR1:TR,

Journal1:Journal

getUser

addLoan

getDocument

addLoan

Page 13: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Invocation order

• Traditional approach• Follow the code• UML 1.x: SD represents one execution path− Decide arbitrarily on if/while choices

• UML 2.x: SD contains alterations, options and loops− Follow the code

• Can you think on Java programs that cannot be analysed in this way?• Limitations of the approach− “Hidden” control flow rules: EJB interceptors

• Limitations of the UML− Java/UML mismatches

/ SET / W&I PAGE 1225-2-2011

Page 14: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

PAGE 13

public class importantClass {

public String importantMethod() { …

}…

}

Logging, security,

performance, …

Flexibility:•How?

•XML file•Annotation

•At what level?•Bean class•Method

•Where?•Bean class•Superclass•Separate class•Injected bean

• 9 complex and interwined laws• Spec is inconsistent with GlassFish

Page 15: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Code Example: Enterprise Java Bean

PAGE 14

package ejb;import ...

@Stateless@Interceptors({Logger.class})public class ProductFacadeextends EJBObject /* it may have an interceptor */implements ProductFacadeRemote {

@PersistenceContextprivate EntityManager em;

...public Product find(Object id) {

return em.find(Product.class, id);}

@Interceptors({Profiler.class})public String productInfo(int id) {

Product product = find(new Integer(id));if (product != null) {

return " Description: "+ product.getDescription();

} else {return null;

}}@AroundInvoke@Overrideprotected Object logMethods(

InvocationContext ctx)throws Exception {...}

}

Page 16: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Example (cont.): XML deployment descriptor

PAGE 15

<assembly-descriptor><!-- Default interceptor -->

<interceptor-binding><ejb-name> * </ejb-name>

<interceptor-class> interceptor.Login </interceptor-class></interceptor-binding>

<!-- Method interceptor --><interceptor-binding>

<ejb-name> ProductFacade </ejb-name><interceptor-class> interceptor.Auditor </interceptor-class><exclude-class-interceptors> true</exclude-class-interceptors>

<method><method-name> productInfo </method-name>

</method></interceptor-binding>

</assembly-descriptor>

Page 17: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Reverse engineered sequence diagram

PAGE 16

:ProductFacade:Login :Profiler

access(ctx)

proceed()

logMethods(ctx)

proceed()

proceed()

ctx:InvocationContext

productInfo(id)

:Auditor

measureDuration(ctx)

proceed()

doAudit(ctx)

find()

em: EntityManager :Product

productInfo(id)

getDescription()

default (xml)

method-level (ann.);class-level def. in Logger is

excluded (xml)

method-level (xml)

class-level (ann.);class-level def. in parent is

overridden

Sounds interesting?

Talk to me!

Opportunity for a Capita Selecta assignment.

Page 18: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Limitations of UML: Java/UML mismatches

• Java semantics does not match UML semantics• UML break

• if the selected interaction occurs, the enclosing interaction is abandoned

• Java break

for (j = 0; j < arrayOfInts.length; j++) { if (arrayOfInts[j] == searchfor) {

foundIt = true; break;

} }

/ SET / W&I PAGE 1725-2-2011

Rountev, Volgin, ReddochPASTE’05

Page 19: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Java/UML mismatches

• Java semantics does not match UML semantics• UML break

• if the selected interaction occurs, the enclosing interaction is abandoned

• Java break search:

for (i = 0; i < arrayOfInts.length; i++) { for (j = 0; j < arrayOfInts[i].length; j++) {

if (arrayOfInts[i][j] == searchfor) { foundIt = true; break search;

} }

} / SET / W&I PAGE 1825-2-2011

Rountev, Volgin, ReddochPASTE’05

Page 20: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Static analysis so far…

• Architecture reconstructor has to decide• Classes or objects

• Methods• Resolve the method calls• Invocation order− May be complex (interceptors)

/ SET / W&I PAGE 1925-2-2011

Page 21: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Dynamic analysis

/ SET / W&I PAGE 2025-2-2011

____________

Code

____________

Instrumented code

Running system

____________

OutputSequence diagram

Page 22: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

What would you like to instrument?

• Source code• Maximal precision

• Compiled code• Example: − gcc -c -pg myfile.c− gcc -pg collatz.o

• Works for any source code• Information is lost

• Execution environment (e.g., Java VM)• Idem

/ SET / W&I PAGE 2125-2-2011

Page 23: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

How to instrument the code?

• Classes: augment with the object identifier• Java: hashCode, rmi.ObjID, etc…

• Add to the trace<currObject,targetObject,methodName,timeStamp>

• Trace ifs and loops• We cannot see the “other way”• We can see the constructs

/ SET / W&I PAGE 2225-2-2011

Page 24: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

How to store the information?

• XML with special tags • MXML, Columbus CAN, …

• Compact Trace Format [Hamou-Lhadj, Lethbridge 2004]

• Common subtrees are represented only once− Similar to ATerms library (ASF+SDF, mCRL2,…)

• XES [Günther 2009]

• Used for process mining

/ SET / W&I PAGE 2325-2-2011

Page 25: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

The Size Explosion problem

/ SET / W&I PAGE 2425-2-2011

• One process in a printer component• 129 calls from the main function• 18 objects (1 per class) involved• Picture does not fit the slide

• Solutions• Smaller scale− “interesting” top-level functions− “interesting” calls in these functions− “interesting” target objects/classes

• Different visualization

Require a priori knowledge

Page 26: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Better visualization (1)

/ SET / W&I PAGE 2525-2-2011

Jerding, Stasko, Ball 1997

Information mural view: general overview in small

Message-flow diagram

One can define interaction patterns and search for their appearances.

Page 27: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Better visualization (2)

/ SET / W&I PAGE 2625-2-2011

Holten, 2009Hierarchy of packages and classesArrow: from greento red

Repeated pattern and exceptional behaviourare clearly visible.Solves the blurring up problem by special visualization technique

Page 28: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Summary so far

• Static and dynamic approaches to sequence diagram reconstruction• Static:− Objects or classes− Resolve the method calls− Invocation order

• Dynamic:− What should be instrumented?− How should it be instrumented?− How should the information be stored?

• Still: size explosion problem• Limitation vs. Visualization

/ SET / W&I PAGE 2725-2-2011

Page 29: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

State machines

• States and transitions

• Usually describe behaviour within one class

• Either• Explicit− Developers intentionally

encode states and transitions

• Implicit• Also useful for model

checking./ SET / W&I PAGE 2825-2-2011

http://franck.fleurey.free.fr/VirtualMeeting/index.html

Page 30: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Explicit State Machine Patterns

• Nested Choice Patterns• Switch/Case –

Switch/Case• Switch/Case – If/Else• If/Else – Switch/Case• If/Else – If/Else

/ SET / W&I PAGE 2925-2-2011

typedef struct {bool initialised;OBJ_STATE state;

} OBJ;...switch (obj->state) {case STATE_A:switch (event) {case EVENT1:obj->state = STATE_B;break;

case EVENT2:obj->state = STATE_C;break;

} break;case STATE_B:switch (event) {case EVENT1:obj->state = STATE_B;break;

case EVENT2:obj->state = STATE_C;break;

} break;...

}

Page 31: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Explicit State Machine Patterns

• Nested Choice Patterns

• Jump Tables• State = a pointer to a

function pointer array (jump table)

• Transitions = function in the jump table

/ SET / W&I PAGE 3025-2-2011

typedef int (*Handler)(char *);

/* The functions */int func0 ( char *event) {

int state;state = … return state;

}…Handler jt[4] =

{func0, func1,func2, func3};

…int main () {

int state;

while(true) {state = jt[state](event);

} }

Page 32: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Explicit State Machine Patterns

• Nested Choice Patterns

• Jump Tables

• Goto statements• States = program

locations• Transitions = goto

• Long jumps• Setjmp: records the

environment• Longjmp: restores the

environment/ SET / W&I PAGE 3125-2-2011

• Object-oriented: State design pattern

Page 33: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Explicit State Machines: Architecture Reconstr.

• Recognize a pattern• And create the state machine

/ SET / W&I PAGE 3225-2-2011

Dennie van Zeeland 2008

Page 34: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Implicit State Machines

• States determined by field values

• Transitions – modification of the field values by methods

/ SET / W&I PAGE 3325-2-2011

Tonella Potrich

class Document {…Loan loan = null;

public void addLoan(Loan ln) {loan = ln;

}public void removeLoan() {

loan = null;}

}

http://Tapulous.com/staff/

Page 35: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

States

• “States determined by field values”• Which fields to chose?

/ SET / W&I PAGE 3425-2-2011

class Document {int documentCode;String title;String authors;String ISBNCode;Loan loan = null;static int nextDocumentCodeAvailable = 0;…

}

Cannot be changed by the class methods (except for constructor)

Changes but class-level!

Page 36: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

States

• “States determined by field values”• Which fields to chose?• Which values to chose?

/ SET / W&I PAGE 3525-2-2011

Loan loanObjects are pointers: many possible values and not all of them are meaningful

• Often groups (equivalence classes) are more meaningful than individual values:

• “Pointer is null” vs. “pointer is not null”• Zero, one or more loans• “temperature is positive and precipitation < 250 mm

per year”

Page 37: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Abstract interpretation (Cousot, Cousot)

• Abstract value – representation of group of concrete values• “positive” represents {x | x > 0}• “woman” represents {x | female(x) /\ adult(x)}

• Abstract domain – set of all possible abstract values• Complete semi-lattice − Partially ordered (≤)− For each two elements there exists a unique lub

• Abstraction – mapping from concrete to abstract val:• α(5) = positive

/ SET / W&I PAGE 3625-2-2011

Page 38: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Abstract Interpretation

/ Faculteit Wiskunde en Informatica PAGE 3725-2-2011

Concrete domain

Concrete domain

Abstract domain

Abstract domain

Computation is difficult or impossible

Abstraction function α

Concretization function γ

Computation is easier

Approximation

⟨A, α, C, γ⟩ should form a Galois connection

Page 39: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Abstract Interpretation: Example

• 2173 × 38 = 81574 or 2173 × 38 = 82574?

• Casting out nines:• Sum the digits in the multiplicand n1, multiplier n2

and the product n to obtain s1, s2 and s. • Divide s1, s2 and s by 9 to compute the remainder,

that is, r1 = s1 mod 9, r2 = s2 mod 9 and r = s mod 9.• If (r1 × r2) mod 9 ≠ r then multiplication is incorrect

• The algorithm returns “incorrect” or “don’t know”

• What are the concrete/abstract domains? Abstraction/concretisation functions?

Page 40: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

To ensure correctness of the abstraction

• ⟨A, α, C, γ⟩ should be a Galois connection • ⟨A, ≤A⟩ and ⟨C, ≤C⟩ are complete semi-lattices− Recap: ≤ and a unique lub

• α:C→A and γ:A→C are monotonic• γ°α:A→A and α°γ:C→C satisfy− c ≤C (γ°α)(c) for all c∈C− (α°γ)(a) ≤A a for all a∈A

• Galois connection guarantees• (α ◦ f C ◦ γ)(a) = a • f C(c) ≤C (γ ◦ f A ◦ α)(c) (*)

γf f

α

γ

α

Page 41: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

State machines?

• Concrete domain: • values of the class fields• functions over the concrete domain: − methods− constructors must be applied first

• Abstract domain:• representation of the sets of the values of the class fields• which sets?− standard techniques (null/not-null, 0-1-many, pos-0-neg)− well-studied domains (intervals, octagons) − determined by comparisons in the code

• functions over the abstract domain− define to satisfy (*)

/ SET / W&I PAGE 4025-2-2011

Page 42: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

State machines reconstruction

1. Initialization:• initStates = ∅• s0 = α(initialization values)• SM = {<●,’’, s0 >}

2. For every constructor cs:• s = csA(s0)• initStates = initStates U {s}• SM = SM U {< s0,cs,s>}

3. toGoStates = initStates

/ SET / W&I PAGE 4125-2-2011

4. while not empty(toGoStates)

• r = select(toGoStates)• toGoStates = toGoStates \ {r}• for each method m− s = mA(r)− SM = SM U {<r,m,s>}− toGoStates = toGoStates U {s}

Page 43: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Example

/ SET / W&I PAGE 4225-2-2011

class Document {…Loan loan = null;

public void addLoan(Loan ln) {loan = ln;

}public void removeLoan() {

loan = null;}

}

s0 (loan = null)

loan ≠ null

addLoan removeLoan

removeLoan

addLoan

Hidden assumptions:• precondition addLoan: ln ≠ null• precondition removeLoan: loan ≠ null

Page 44: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

State machine reconstruction: Summary

• State machines• Popular for object behaviour specification• Can be used for model checking

• Explicit state machines• Designed by a developer• Patterns

• Implicit state machines• Abstract interpretation

/ SET / W&I PAGE 4325-2-2011

Page 45: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Part 2: Architecture (last week)

• As intended

• As described• Architecture Description Languages− Should express different views

• As implemented• Code, deployment• From code to architecture: reverse engineering− Should extract different views

/ SET / W&I PAGE 4425-2-2011

evolution

evolution

Page 46: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Current ADLs target

• Correctness: e.g., Wright [Allen 1997]

− based on Communicating Sequential Processes − defines consistency properties− that can be checked using model checking

• System config. and code generation, e.g., • Fractal [Bruneton, Coupaye, Leclercq, Quema, Stefani 2004]

− components: primitive (code) and composite (group) − code generation

• ArchJava [Aldrich, Chambers, Notkin 2002]

− extension of Java − components, ports, connections

− enforces communication integrity/ SET / W&I PAGE 4525-2-2011

public component class Parser {public port in {

provides void setInfo(Token symbol,SymTabEntry e);

requires Token nextToken()throws ScanException;}

public port out {provides SymTabEntry getInfo(Token t);requires void compile(AST ast);}

Page 47: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Major problems with current ADLs

• No support for evolution during the execution• Architecture can change during the execution:− client connects to a different server

• Snapshots easily become obsolete• No support for evolution due to change in

requirements• Wright − model checking: no incremental approach− minor property/model modification ⇒ everything

should be rechecked• ArchJava− no real separation of architecture/implementation− overtly complex code

/ SET / W&I PAGE 4625-2-2011

Page 48: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

First attempts at solutions: Extended Wright

• Event-driven reconfiguration• Component description should be adapted to describe

when/which reconfigurations are permitted• Incomplete separation of the reconfiguration policies

• Can be used to model evolution, but• Finite number of models

/ SET / W&I PAGE 4725-2-2011

Architectural model

Architectural model

Architectural model

Page 49: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Architecture Description Languages

• Minimal support for evolution• Only run-time

• Use of an ADL can even hinder evolution

• On-going research

/ SET / W&I PAGE 4825-2-2011

Page 50: Architecture Evolution - Eindhoven University of Technologyaserebre/2IS55/2010-2011/4.pdf · Architecture Evolution Alexander Serebrenik. Assignments: Reminder • Assignment 2: •

Conclusions

• Behaviour reconstruction• Classes or objects• Sequence diagrams or state machines• Statically or dynamically• Visualization

• ADL

• Next week (March 2): invited lecture by Stijn Hoop• March 9: Carnaval • March 16: Deadline Assignment 3

/ SET / W&I PAGE 4925-2-2011