130 likes | 202 Views
Address information loss in graph traversals by visually displaying copies with colors, optimizing project outputs from source to target nodes. Implement law of Demeter for modular concerns separation.
E N D
A B C U 0..1 D X R S E F Class Graph
Project Output from A via X to F = {source:A -> X X ->target:F} A B C U 0..1 Problem: Information loss: A B D E F not allowed! D X R S E F
Remember the copies in a traversal graph? Show them with colors. Better Project Output from A via X to F = {source:A -> XX ->target:F} A U B C 0..1 Problem: Information loss: A B D E F not allowed! But now we know that D is in two traversals D X R S E Dashed: multiple F
Better Project Output from A via R to F = {source:A -> RR ->target:F} A U B C 0..1 No information loss D X R S E F
Project Output A from A to F B C U Selects all Nodes and edges 0..1 D X R S E F
A from A to S B C U 0..1 D X R S E F Project Output
A B C U 0..1 D X R S E F object graph a1111 class graph new A( new B( new D( new E( new F(7)), new X( new F(9), new D( new E( new F(27)), new X( new F(35),null))))), new C( new R( new X( new F(15), null), new F(20))))
A a:A :B B :C C U 0..1 D :D X :X R :S S E :E F f2:F f1:F ObjectGraph a class graph
A U B C 0..1 D X R S E F S 1 object graph 4 way pattern matching class graph a1111 = new A( new B( new D( new E( new F(7)), new X( new F(9), new D( new E( new F(27)), new X( new F(35),null))))), new C( new R( new X( new F(15), null), new F(20)))) T1 = s2 t2 Visitor: A,B,C,D,E,F,X ( before ) after from A via X to F = {source:A -> XX ->target:F} after X after C after A
A U B C 0..1 D X R S E F cg.gather(a,”from A via X to F”); Returns list of size 1!!! Object graph 3 way pattern matching a:A :B :C :D :X :S from A via X to F :E f2:F f1:F
A cg.gather(a,”from A to F”); Returns list of size 2 Class graph B C U Object graph 3 way pattern matching a:A 0..1 D X R S :B :C E F :D :X :S But S is not a target :E f2:F f1:F
cg.gather(a,”from A to S”); Returns list of size 1 A from A to S 3 way pattern matching a:A B C U 0..1 :B :C D X R S :D E :X :S F :E f2:F f1:F
Law of Demeter for Concerns • Each module should only talk to its friends that share the same concerns. • Some concerns are inherently linked that it is not worthwhile separating them. • Each module deals with a small number of concerns.