200 likes | 348 Views
An Empirical Study of the Demeter System. Pengcheng Wu and Mitchell Wand Northeastern University. Motivation. Collect evidence to support the claim: Demeter system improves the – ilities of software systems. In this talk, we focus on a specific – ility : Comprehensibility.
E N D
An Empirical Study of the Demeter System Pengcheng Wu and Mitchell Wand Northeastern University
Motivation • Collect evidence to support the claim: Demeter system improves the –ilities of software systems. • In this talk, we focus on a specific –ility: Comprehensibility.
Problem addressed: manual implementation of a traversal on a complex object structure is tedious and error-prone. E.g., AST traversal. Solution: have a high-level description of traversals, then generate the code! System overview
Demeter’s high-level traversal language: strategy Subgraph of transitive closure of class graph Graph language: may be cyclic E.g., from class A via class B to class E A bunch of traversal generating algorithms. E.g., FIRST algorithm [Lieberherr and Wand 2002] System overview (cont.)
from A via B to E class A { void t1() { if(b!=null) b.t1(); } void t1prime() { access(e); if(b!=null) b.t1(); } } class B { void t1() { d.t1(); } } class D { void t1() { a.t1prime(); } } FIRST Algorithm
from A via B to E High-level description is much easier to understand! class A { void t1() { if(b!=null) b.t1(); } void t1prime() { access(e); if(b!=null) b.t1(); } } class B { void t1() { d.t1(); } } class D { void t1() { a.t1prime(); } }
Q: Do you have any more convincing statistics? • A: YES! The largest software system using Demeter’s traversal strategies: the DemeterJ Compiler. It has 413 classes, 80 traversals on ASTs
Traversal strategies improve comprehensibility • How to measure the improvement? Abstractness of a traversal strategy =Length(MethodCallPaths)/Length(Strategy) The larger the ratio is, the more abstract the strategy is, then the more details are left out and the better comprehensibility we achieve.
Conclusion • Traversals on complex object structures tend to be complex too. • High level description of traversals helps improve the comprehensibility of the traversal concerns in software system. • The improvements are nontrivial.
Specific, explicit, closed Controls spuriousness Leads to Brittleness Predictability Rigidity Generic, implicit, open-ended Controls brittleness Leads to Spuriousness comprehensability Evolvability Tradeoff in AOP
Specific, explicit, closed Controls spuriousness Leads to Brittleness Predictability Rigidity Complex request to base Hospital, go left,right,up Base can refuse Generic, implicit, open-ended Controls brittleness Leads to Spuriousness comprehensability Evolvability Complex request to base Place where they heal people Tradeoff in AOP
Edinburgh, Scottish symbols • Mik: • Effects of control flow advice • Query languages • 3 layer structure, editing at second layer
NSF design proposal • CME and Demeter • Use selector language to define editing • Selector language needs unification, pattern matching • Enhancement: SelectorExpression(p1, … ) {body}
Mario • Visitor makes assumptions on class graph • Analyze traversal graph: another graph intersection
Pengcheng • Traversal graph: pcd and call graph • call f()) from main() to call f() • cflow(call f()) = from main() via call f() to * • Cflow(p) = from main() via pathset to * • Pathset starts at Main • Join(Pathset(p), target(…) to *
!call f() = !pathset(from main to f()) • Same source, same target: all other paths • !(from A to B) : from A to !B: forward from A, backward from all other nodes • !(from A via B to C) = from A via !B to C or from A via B to !C or from A via !B to !C • !([A,B].[B,C]) =[A,!B].[!B,C] or [A,B][B,!C] • !(D1.D2) =!D1.D2’ || D1.!D2