Title: Modeling, Measuring, and Modularizing Crosscutting Concerns
1Modeling, Measuring, and ModularizingCrosscuttin
g Concerns
- Thesis Proposal Defense
- 12/13/06
- Marc Eaddy
2Motivation
3My thesis in a nutshell
- Improve understanding of crosscutting concerns
and how they impact modularity, and suggest ways
to reduce the impact - Modularity is essential for understandable,
maintainable, and evolvable software - Crosscutting concerns hinder modularity, but no
one knows how much - Crosscutting concern concept is ill-defined
- Impact on modularity insufficiently understood
and quantified - My solution New formal model and metrics
- Existing approaches for modularizing crosscutting
concerns actually hinder modularity - My solution New language that improves modularity
4Outline
- Importance of modular design
- Crosscutting concerns
- Concern model
- Crosscutting metrics
- Case study
- Advanced separation of concerns
- Wicca
- Timeline
- Conclusion
5Modular design
- Division of a large program into smaller
logically self-contained subprograms (modules) - Arguably the most important design property of a
program - Simplifies the program
- Enables separation of concerns (Dijkstra)
- Enables modular reasoning
- Example Information hiding (Parnas)
- Enables independent development and testing
- Example Interfaces
- Improves reusability and substitutability
- Example Abstract data types (Liskov)
- Reduces impact of changes
6Software concerns
- Any consideration about the implementation of a
program - Features, requirements, policies, design rules,
etc. - Some concerns easy to modularize (e.g., using OO)
- Person
- Shape
- Socket
- Some concerns difficult to modularize using a
particular decomposition technique - Tyranny of the dominant decomposition
- Expression problem
- Error handling
- Collision detection
7Goblin Game AI
8Goblin Collision detection
- Collision detection is scattered
(crosscutting)
9A crosscutting concern
Scatters its implementation across many modules
Reduces programs overall modularity
Makes program harder to understand, develop in
parallel, maintain, and evolve
10Problem Crosscutting ill-defined
- A concern can be anything
- A concern can crosscut anything
- Common AOP terms ill-defined
- scattered, tangled, crosscutting
- Easy to concoct arguments to favor proposed
solution - Hard to evaluate solutions
11Solution Formal concern model
- Concern model (S, T, R)
- S Source domain (e.g., concern domain)
- T Target domain (e.g., component specifications)
- R Relation on SxT (e.g., implemented by
relation)
12Formal terminology
13Model contributions
- Formalizes terminology and concepts
- Crosscutting, concern, scattered, tangled
- S, T, and R should be well-defined
- Generally applicable
- Supports all concern and component types
- Existing formalisms expressible using my model
- Many CS areas reduced to finding S, T, or R
- Applicable to non-CS domains
- Solid math. foundation for measuring crosscutting
14Related work (model)
- Robillard and Murphy, Concern Graphs
- No formal definitions for AOP terminology
- No metrics
- Coppit et al., Software Plans
- No formal definitions for AOP terminology
- Not suitable for defining metrics
15Problem Crosscutting impact insufficiently
quantified
- Concerns are informal (subjective) and incomplete
- Conclusions are questionable
- Metrics are crude
- Spread metric (Lai and Murphy, Revelle et al.),
diffusion metrics (Garcia et al.) - Measure presence of a concern, not degree
- Cannot distinguish between a concern split 50-50
and 99-1 - Cannot distinguish the impact of refactorings
16Solution Crosscutting metrics
- Adapted and extended closeness metrics to measure
crosscutting - Concentration Amount of a concerns
implementation that is contained in a specific
component
W. E. Wong, S. G. Swapna, and R. H. Joseph,
"Quantifying the closeness between program
components and features," Journal of Systems and
Software, 2000.
17Solution Crosscutting metrics
- Adapted and extended closeness metrics to measure
crosscutting - Concentration Amount of a concerns
implementation that is contained in a specific
component
of components statements related to the concern
Total of statements related to the concern
W. E. Wong, S. G. Swapna, and R. H. Joseph,
"Quantifying the closeness between program
components and features," Journal of Systems and
Software, 2000.
18Solution Crosscutting metrics
- Adapted and extended closeness metrics to measure
crosscutting - Concentration Amount of a concerns
implementation that is contained in a specific
component - Dedication Amount of a components
implementation that is related to a specific
concern ( extended to handle tangled concerns)
of components statements related to the concern
Total of statements related to the concern
W. E. Wong, S. G. Swapna, and R. H. Joseph,
"Quantifying the closeness between program
components and features," Journal of Systems and
Software, 2000.
19Solution Crosscutting metrics
- Adapted and extended closeness metrics to measure
crosscutting - Concentration Amount of a concerns
implementation that is contained in a specific
component - Dedication Amount of a components
implementation that is related to a specific
concern ( extended to handle tangled concerns)
of components statements related to the concern
Total of statements related to the concern
Total of components statements
W. E. Wong, S. G. Swapna, and R. H. Joseph,
"Quantifying the closeness between program
components and features," Journal of Systems and
Software, 2000.
20Solution Crosscutting metrics
- Adapted and extended closeness metrics to measure
crosscutting - Concentration Amount of a concerns
implementation that is contained in a specific
component - Dedication Amount of a components
implementation that is related to a specific
concern ( extended to handle tangled concerns) - Closeness metrics provide data points, not
insight - Unwieldy for measuring the impact of a refactoring
of components statements related to the concern
Total of statements related to the concern
Total of components statements
W. E. Wong, S. G. Swapna, and R. H. Joseph,
"Quantifying the closeness between program
components and features," Journal of Systems and
Software, 2000.
21My metrics DOS
- Degree of scattering Measures the distribution
of a concerns implementation across multiple
components
22My metrics DOS
- Degree of scattering Measures the distribution
of a concerns implementation across multiple
components - Average DOS Overall modularity of concerns
- Summarizes amount of crosscutting present
- More insightful than traditional metrics
- class A is highly coupled vs. feature A is
hard to change
23My metrics DOF
- Degree of focus Degree to which a components
implementation relates to multiple concerns - Average DOF Overall separation of concerns
24Goodness of metrics
- Counterbalance each other
- Correlate with intuition
- Obviously good C/C refactorings
- Promising preliminary results
- Crosscutting is very sensitive to S, T, and R
- Metrics useful for program comprehension
- Not all crosscutting needs to be fixed
- Nonfunctional reqs not always crosscutting
- Localized not always equal to modularized
- (This is really great. Nachi Nagappan)
25Metrics caveats
- Manual concern identification impractical
- Only tell part of the modularity story
- More evidence needed before I can generalize
- More case studies
- Multiple concern identifiers (e.g., grad
students) - Comparison to previous case studies and results
26Case study
- Validate model and metrics
- Obtain insight into crosscutting
- Nature of crosscutting
- Scope of crosscutting problem
- Amount of latent modularity potential
- Limits of modularity
- Inform design of new modularization technique
(Wicca) - Compare modularization techniques
- AspectJ, Wicca
27Subject Goblin
- Platform for building 3D applications and games
- 14,500 source lines of C
- Designed and partially implemented by me
28Case study phases
Concern tagging using statement annotations
statistics gathering
Implement AspectJ-like featuresin Phx.Morph v1.2
Design and implement Wicca
29Advanced separation of concerns
- Aspect-, feature-, subject- oriented programming
- Multi-dimensional separation of concerns
- Open classes
- Metaprogramming
- etc.
30Problem ASOC hurts modularity
31Solution
Wicca
- Goal
- Actually modularize crosscutting concerns
(i.e., without sacrificing other modularity
properties) - Extends C to support
- Side classes
- Statement annotations
32Side classes
- Powerful and disciplined class extension
33Statement annotations
Allows any program statement to be annotated
//Concern("Input") inputMapper.Update(elapsedTim
e)
- Relating code to concerns (R)
- Indicating code injection locations (AOP)
- Specifying
- Optimization and parallelization hints
- Contracts
- Fault isolation for injected/generated code
- Reducing concern scattering
- Statement Annotations for Fine-Grained
Advising, RAM-SE 2006
34Related work (language design)
- Unification of AO and OO (C)
- Example Eos
- Removed asymmetry between aspects and classes
- However, unification is deeper in Wicca
- Advising mechanism method overloading
- Introduction mechanism base class derivation
- Language restrictions to enable modular reasoning
- Examples Crosscut Program Interfaces,
Aspect-Aware Interfaces, Open Modules - Advising more explicit, but not well integrated
with OO
35Timeline
36Conclusion
37Conclusion
38Conclusion
sideClasses
Wicca
_at_Statement
39Thank you!
40Expression problem revisited
- Language parsing
- Expressions Literal, Add, etc.
- Operations eval, print, etc.
- Task Cache expression evaluation
- class AddExpr Expression
- virtual Expression left, right
- public virtual AddExpr(Expression left,
Expression right) - this.left left this.right right
-
- public int eval() return left.eval()
right.eval() -
41Side class Caching eval
- class AddExpr Observer
- int cache bool isCacheValid false
-
- public override AddExpr( Expression left,
- Expression right)
- base(left, right)
- this.left.observer this
- this.right.observer this
-
- void Observer.update() isCacheValid false
- ...
42Side class Caching eval
Interface and member Introduction
- class AddExpr Observer
- int cache bool isCacheValid false
-
- public override AddExpr( Expression left,
- Expression right)
- base(left, right)
- this.left.observer this
- this.right.observer this
-
-
- void Observer.update() isCacheValid false
- ...
Anonymousside class
Call next delegate
Base constructor override
43Cache expression evaluation
- class AddExpr Observer
- ...
- override public int eval()
- if (!isCacheValid)
- cache base.eval()
- isCacheValid true
-
- return cache
-
- ...
44Cache expression evaluation
- class AddExpr Observer
- ...
- override public int eval()
- if (!isCacheValid)
- cache base.eval()
- isCacheValid true
-
- return cache
-
- ...
Call next delegate
45Property change notification
- class AddExpr Observer
- ...
- override Expression which left right
- set
- base.which value
- which.observer this
- if (observer ! null)
- observer.update()
-
-
-
46Property change notification
- class AddExpr Observer
- ...
- override Expression which left right
- set
- base.which value
- which.observer this
- if (observer ! null)
- observer.update()
-
-
-
Metavariables
Limited quantification
Override virtual field
47My metrics DOT
- Degree of tangling Degree to which a concern
shares its implementation with other concerns - Average DOT Overall concern coupling
48My metrics DOT
- Degree of tangling Degree to which a concern
shares its implementation with other concerns - Average DOT Overall concern coupling
of nonshared statements related to the concern
Total of statements related to the concern