Title: Class Graph
1Class Graph
2Project Output
from A via X to F sourceA -gt X X -gttargetF
A
B
C
U
0..1
Problem Information loss A B D E F not allowed!
D
R
S
X
E
F
3Better Project Output
Remember the copies in a traversal graph? Show
them with colors.
from A via X to F sourceA -gt X X -gttargetF
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
R
S
X
E
Dashed multiple
F
4Better Project Output
from A via R to F sourceA -gt R R -gttargetF
A
U
B
C
0..1
No information loss
D
R
S
X
E
F
5Project Output
A
from A to F
B
C
U
Selects all Nodes and edges
0..1
D
R
S
X
E
F
6Project Output
7object 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))))
8ObjectGraph a
class graph
9object 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))))
Visitor A,B,C,D,E,F,X
( before ) after
from A via X to F sourceA -gt X X -gttargetF
after X
after A
after C
10cg.gather(a,from A via X to F) Returns list of
size 1!!!
Object graph
3 way pattern matching
aA
B
C
D
S
X
from A via X to F
E
f2F
f1F
11A
cg.gather(a,from A to F) Returns list of size 2
Class graph
B
C
U
Object graph
3 way pattern matching
aA
0..1
D
R
S
X
B
C
E
F
D
S
X
But S is not a target
E
f2F
f1F
12cg.gather(a,from A to S) Returns list of size 1
A
from A to S
3 way pattern matching
aA
B
C
U
0..1
B
C
D
R
S
X
D
E
S
X
F
E
f2F
f1F
13Law 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.