APPCs revisited 952021 APPCs revisited 1 APPCs motivation

  • Slides: 23
Download presentation
APPCs revisited 9/5/2021 APPCs revisited 1

APPCs revisited 9/5/2021 APPCs revisited 1

APPCs: motivation • Want classes and collaborations – Want variation-oriented programming • incremental change

APPCs: motivation • Want classes and collaborations – Want variation-oriented programming • incremental change of collaborations by code addition instead of individual class editing – Want traversal strategies • structure-shyness and partially automated evolution 9/5/2021 APPCs revisited 2

Composition of APPCs, strategies and class graphs APPCs Strategy types gv 1 gv 2

Composition of APPCs, strategies and class graphs APPCs Strategy types gv 1 gv 2 st 1 s 1 = refinement of st 1 for CG 1 gv 2(gv 1)(s 1 CG 1) 9/5/2021 instantiated behavior s 1 st 1 Class graphs gv 1 CG 2 gv 2 AOO 3

Loose coupling C S Strategy graphs Class graphs APPCs 9/5/2021 F AOO Each unit

Loose coupling C S Strategy graphs Class graphs APPCs 9/5/2021 F AOO Each unit should hard-code as few assumptions as possible on the concrete form of the others. 4

Roles of strategy graph • Participant management role – define set of participants reachable

Roles of strategy graph • Participant management role – define set of participants reachable from a classvalued variable – define participant transportation – participant name : abbreviation for path or reversed path • Super-iterator role – iterate while executing code of some APPC 9/5/2021 APPCs revisited 5

Roles of strategy graph • Participant management role – forward path abbreviation • From

Roles of strategy graph • Participant management role – forward path abbreviation • From a: A via b: B to c: C – if unique path, c is abbreviation for path (used in A-object or B-object) – backward path abbreviation • From a: A via b: B to c: C – if in C-object we need the last B-object visited, b is abbreviation for reversed unique path (used in C-object) 9/5/2021 APPCs revisited 6

Participant management role • Interesting definition: unique reverse path Part. List Loop does not

Participant management role • Interesting definition: unique reverse path Part. List Loop does not matter for reverse path Class. Def Part Empty Non. Empty Reverse path from Part to Class. Def is unique. 9/5/2021 APPCs revisited 7

Super-iterator role • Traverse and execute code of an APPC (visitor style). – o.

Super-iterator role • Traverse and execute code of an APPC (visitor style). – o. strategy(APPC) • can be anywhere in a method – f() strategy(APPC) • introduce name f and then call o. f() 9/5/2021 APPCs revisited 8

Playing both roles • Participant management role and superiterator role. – Adjacency to edge-list

Playing both roles • Participant management role and superiterator role. – Adjacency to edge-list translation • participant transportation along unique backward paths (backward path abbreviation) • use same strategy as super-iterator – Pricing • set of participants along unique paths (forward path abbreviation) • us same strategy as super-iterator 9/5/2021 APPCs revisited 9

APPC • Consists of – provided interface • methods to class-valued variables • output

APPC • Consists of – provided interface • methods to class-valued variables • output port to other components – required interface • methods from class-valued variables • interface to class graph: paths required • input ports from other components – implementation 9/5/2021 APPCs revisited 10

APPC • Required interface – methods from class-valued variables – interface to class graph:

APPC • Required interface – methods from class-valued variables – interface to class graph: paths required • A set of traversal strategies – for participant management (unique forward and backward paths) – as super-iterators – input ports from other components 9/5/2021 APPCs revisited 11

APPC • Implementation – methods: refer to participants – methods may call • next():

APPC • Implementation – methods: refer to participants – methods may call • next(): result from next component • next(). n: result from component n • subtraversal(). s: continue traversal following strategy edge s ? ? 9/5/2021 APPCs revisited 12

Compositionality and referring to traversals in APPC code • Should keep it simple: go_on()

Compositionality and referring to traversals in APPC code • Should keep it simple: go_on() (or next()) should be only way to talk about what to do next. • Reason: we want to compose several APPCs and if each of them talks about its own way of navigation, it is not clear what composition means 9/5/2021 APPCs revisited 13

Kinds of APPCs • Visitor style – single-traversal collaborations – addition or modification for

Kinds of APPCs • Visitor style – single-traversal collaborations – addition or modification for duration of traversal • Adjuster style – multi-traversal collaborations – add statically new methods to groups of classes – statically modify methods in groups of classes 9/5/2021 APPCs revisited 14

Both kinds • Parameterized by – strategies – class-valued variables – method-valued variables 9/5/2021

Both kinds • Parameterized by – strategies – class-valued variables – method-valued variables 9/5/2021 APPCs revisited 15

Kinds of APPCs • Visitor style – single-traversal collaborations • single strategy parameter, uniform

Kinds of APPCs • Visitor style – single-traversal collaborations • single strategy parameter, uniform single method name backbone of collaboration • calls subtraversal(). s // follow down strategy edge s ? ? 9/5/2021 APPCs revisited 16

Kinds of APPCs • Adjuster/Contract style – multi-traversal collaborations • several strategy parameters •

Kinds of APPCs • Adjuster/Contract style – multi-traversal collaborations • several strategy parameters • different method names 9/5/2021 APPCs revisited 17

Role of strategy graph • At some class A we don’t call next() only.

Role of strategy graph • At some class A we don’t call next() only. Can call subtraversal(). x and subtraversal(). y with any Java code in between. ? ? ? • Strategy graph describes where we might traverse: is the case anyway with around methods. ? ? ? 9/5/2021 APPCs revisited 18

APPCs: visitor style APPC A (St 1 s 1){ instance variables methods B {

APPCs: visitor style APPC A (St 1 s 1){ instance variables methods B { // redefines node code instance variables, methods St 1 strategy type void my_role(){ describing the collaboration. { … next(); … } K, L appear in St 1 } -> X, y, Y { // redefines edge code void my_role() { … next(); … } } } 9/5/2021 APPCs revisited 19

Structure of an APPC (visitor style) APPC (Strategy s, Method m 1, …, mk){

Structure of an APPC (visitor style) APPC (Strategy s, Method m 1, …, mk){ // visitor style has only one strategy argument //variables global for traversal init()… return()… start()… final()… s. source //variables that temp. extend host object init()… my_role() host. m 1(); … next-visitor. return; … next(); host. local. Method 1(); … local. Method 1()(@ … @); … }// end of APPC 9/5/2021 AOO 20

APPC: adjuster style APPC A (St 1 s 1, St 2 s 2, …){

APPC: adjuster style APPC A (St 1 s 1, St 2 s 2, …){ B { void f 1() { { x. f 2(); … next(); …} } Add new methods f 1 and f 2 to classes } B and C, respectively. C { void f 2() { … } } } 9/5/2021 APPCs revisited 21

Open issues • Composition of APPCs – order – modifies/assumes/extends – uses • Integrate

Open issues • Composition of APPCs – order – modifies/assumes/extends – uses • Integrate visitor style and adjuster style? – Visitor a special case of adjuster style • Injecting APPCs into class graph 9/5/2021 APPCs revisited 22

Open issues • Subtraversals: strategic traversal automaton • using APPCs as arguments to other

Open issues • Subtraversals: strategic traversal automaton • using APPCs as arguments to other APPCs or parts of them – like a uses relationship 9/5/2021 APPCs revisited 23