Upload
sailqu
View
89
Download
0
Embed Size (px)
Citation preview
IdentifyingCrosscutting Concerns
Using Historical Code Changes
Bram AdamsZhen Ming JiangAhmed E. Hassan
SAIL, Queen's Universityhttp://sailhome.cs.queensu.ca/~bram/
What are crosscutting concerns?
2
CrosscuttingConcerns
3
CrosscuttingConcerns
3
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
3
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
3
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
3
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
3
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
3
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
3
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
3
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
3
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
3
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
3
1. Which concerns are implemented?
2. Where?
3. How are concerns composed together?
(Crosscutting) Concern Mining
4
1. What is a Crosscutting Concern?
2. The Concern Mining Process and its Shortcomings
3. COMMIT
4. Case Study
5. Conclusion
5
Concern Mining Process
datasource
6
Concern Mining Process
datasource
concernseeds
1
6
Concern Mining Process
datasource
concernseeds
Concern Mining Techniques :-)
1
6
Concern Mining Process
datasource
concernseeds
Concern Mining Techniques :-)
concerns
1 2
6
Concern Mining Process
datasource
concernseeds
expandedconcerns
Concern Mining Techniques :-)
concerns
1 2 3
6
Concern Mining Process
datasource
concernseeds
expandedconcerns
concerncomposition
Concern Mining Techniques :-)
concerns
1 2 3 4
6
Concern Mining Process
datasource
concernseeds
expandedconcerns
concerncomposition
Concern Mining Techniques :-)
MANUAL :-(
concerns
1 2 3 4
6
Concern Mining Process
datasource
concernseeds
expandedconcerns
concerncomposition
Concern Mining Techniques :-)
MANUAL :-(
concerns
1 2 3 4
6
S1: Limited Context
1 2 3 4
7
S1: Limited Context
thread()
process()
block()
clean()
1 2 3 4
7
S1: Limited Context
thread()
process()
mutex
semaphore_t
addresssender subject
block()
DEFINED_LINUX
clean()
1 2 3 4
7
S1: Limited Context
thread()
process()
mutex
semaphore_t
addresssender subject
CVS
block()
DEFINED_LINUX
clean()
thread()
1 2 3 4
7
S2: Noise1 2 3 4
8
S2: Noise1 2 3 4
8
S2: Noise1 2 3 4
8
S3: NoComposition
random
encrypt
decrypt
seed
1 2 3 4
9
S3: NoComposition
random
encrypt
decrypt
seed
random
encrypt
decrypt
seed
1 2 3 4
9
1. What is a Crosscutting Concern?
2. The Concern Mining Process and its Shortcomings
3. COMMIT
4. Case Study
5. Conclusion
10
COncern Mining using Mutual Information over Time
CVS
11
limited context
noise
no composition
COncern Mining using Mutual Information over Time
analyze historical changes to all code entities
CVS
11
limited context
noise
no composition
COncern Mining using Mutual Information over Time
analyze historical changes to all code entities
statistical clustering based on mutual information
CVS
11
limited context
noise
no composition
S1. Historical Data Sources
CVS
CVS
12
S1. Historical Data Sources
CVS
transactions
CVS
12
S1. Historical Data Sources
CVS
transactions
CVS
12
S1. Historical Data Sources
CVS
transactions
CVS
function call or variable access added
12
S1. Historical Data Sources
CVS
transactions
CVS
function call or variable access added
intentional co-addition of calls and
accesses12
S1. Historical Data Sources
CVS
transactions
CVS
function call or variable access added
intentional co-addition of calls and
accesses
concernseed
12
S2. MutualInformation
13
S2. MutualInformation
13
S2. MutualInformation
13
S2. MutualInformation
13
S2. MutualInformation
13
S2. MutualInformation
13
S2. MutualInformation
13
S2. MutualInformation
13
S2. MutualInformation
13
S2. MutualInformation
13
S2. MutualInformation
13
S2. MutualInformation
13
S2. MutualInformation
13
S2. MutualInformation
14
How much does occurrence of
reveal about occurrence of ?
S2. MutualInformation
14
How much does occurrence of
reveal about occurrence of ?
S2. MutualInformation
14
How much does occurrence of
reveal about occurrence of ?
S2. MutualInformation
14
How much does occurrence of
reveal about occurrence of ?
S2. MutualInformation
14
How much does occurrence of
reveal about occurrence of ?
S2. MutualInformation
14
S3. Concern Relations
seed graph
15
S3. Concern Relations
15
S3. Concern Relations
compositeconcern
simpleconcern
15
1. What is a Crosscutting Concern?
2. The Concern Mining Process and its Shortcomings
3. COMMIT
4. Case Study
5. Conclusion
16
Case Study
1996-2002 1993-2003(800 kLOC) (2 MLOC)
17
Comparative Study
18
CBFA
HAM
COMMIT
similar entity names ✖
identical set of callers ✖
mutual information ✔
limited context
noise no composition
Comparative Study
18
CBFA
HAM
COMMIT
similar entity names ✖
identical set of callers ✖
mutual information ✔
limited context
noise no composition
Comparative Study
18
CBFA
HAM
COMMIT
similar entity names ✖
identical set of callers ✖
mutual information ✔
limited context
noise no composition
CVS
CVS
snapshot
Comparative Study
18
CBFA
HAM
COMMIT
similar entity names ✖
identical set of callers ✖
mutual information ✔
limited context
noise no composition
CVS
CVS
snapshot
Comparative Study
18
CBFA
HAM
COMMIT
similar entity names ✖
identical set of callers ✖
mutual information ✔
limited context
noise no composition
CVS
CVS
snapshot
Study Design
19
Study Design
19
Study Design
CBFA
HAM
COMMIT
19
Study Design
CBFA
HAM
COMMIT
top 20
top 20
top 20
19
Study Design
CBFA
HAM
COMMIT
top 20
top 20
top 20
19
concern?
Study Design
CBFA
HAM
COMMIT
top 20
top 20
top 20
19
Study Design
CBFA
HAM
COMMIT
19
Study Design
CBFA
HAM
COMMIT
19
Study Design
CBFA
HAM
COMMIT
top 20
top 20
top 20
19
Study Design
CBFA
HAM
COMMIT
top 20
top 20
top 20
19
top 20
top 20
top 20
H1. Richer Data Sources Yield richer Seeds
CVS
20
H1. Richer Data Sources Yield richer Seeds
0
8
16
24
32
40
CBFA HAM COMMIT0
45
90
135
180
225
CBFA HAM COMMIT
#non-function entities
#functions
CVS
20
H1. Richer Data Sources Yield richer Seeds
0
8
16
24
32
40
CBFA HAM COMMIT0
45
90
135
180
225
CBFA HAM COMMIT
#non-function entities
#functions
CVS
20
50%
79% 83%
29% 88%75%
H2. COMMIT Identifies a Larger Percentage of unique Concerns
21
H2. COMMIT Identifies a Larger Percentage of unique Concerns
21
0
20
40
60
80
100
CBFA HAM COMMIT0
20
40
60
80
100
CBFA HAM COMMIT
H2. COMMIT Identifies a Larger Percentage of unique Concerns
21
0
20
40
60
80
100
CBFA HAM COMMIT
56% 56%
0
20
40
60
80
100
CBFA HAM COMMIT
87.5% 50%
H3. COMMIT complements CBFA and HAM (1)
22
H3. COMMIT complements CBFA and HAM (1)
22
CBFA HAM
COMMIT
0 0 1
08
14
9
CBFA HAM
COMMIT
1 0 0
09
14
9
H3. COMMIT complements CBFA and HAM (2)
23
d1 d2 d3 d4 d5 d6 d7 d8 d9
H3. COMMIT complements CBFA and HAM (2)
device drivers23
kernel
d1 d2 d3 d4 d5 d6 d7 d8 d9
H3. COMMIT complements CBFA and HAM (2)
CBFA concern(e.g., driver API)
23
kernel
d1 d2 d3 d4 d5 d6 d7 d8 d9
H3. COMMIT complements CBFA and HAM (2)
CBFA concern(e.g., driver API)
HAM concern(e.g., cloned driver code)
23
kernel
d1 d2 d3 d4 d5 d6 d7 d8 d9
H3. COMMIT complements CBFA and HAM (2)
CBFA concern(e.g., driver API)
HAM concern(e.g., cloned driver code)
COMMIT concern(e.g., driver + infrastructure)
23
kernel
d1 d2 d3 d4 d5 d6 d7 d8 d9
H3. COMMIT complements CBFA and HAM (2)
CBFA concern(e.g., driver API)
HAM concern(e.g., cloned driver code)
COMMIT concern(e.g., driver + infrastructure)
23
kernel
24
ODBC Data RetrievalComposite Concern
24
ODBC Data RetrievalComposite Concern1. connection configuration
1
24
ODBC Data RetrievalComposite Concern
ODBC
1. connection configuration
12
24
ODBC Data RetrievalComposite Concern
ODBC
1. connection configuration2. connection error handling
1 32
24
ODBC Data RetrievalComposite Concern
ODBC
1. connection configuration2. connection error handling3. data transfer
1 32
424
ODBC Data RetrievalComposite Concern
ODBC
1. connection configuration2. connection error handling3. data transfer4. SQL-to-ODBC conversion
1 32
4524
ODBC Data RetrievalComposite Concern
ODBC
1. connection configuration2. connection error handling3. data transfer4. SQL-to-ODBC conversion5. ODBC-to-ESQL conversion
1 32
645
24
ODBC Data RetrievalComposite Concern
ODBC
1. connection configuration2. connection error handling3. data transfer4. SQL-to-ODBC conversion5. ODBC-to-ESQL conversion6. conversion error handling
13
4
62
1 32
645
5
24
ODBC Data RetrievalComposite Concern
ODBC
1. connection configuration2. connection error handling3. data transfer4. SQL-to-ODBC conversion5. ODBC-to-ESQL conversion6. conversion error handling
36 seeds
25
36 seeds
ODBC Data Retrieval Concern
25
36 seeds
ODBC Data Retrieval Concern
25
5 other composite concerns
Threats to Validity
• generalizability to other systems
• subjectivity ↔ substantial agreement (Kappa)
• seed quality not checked
• threshold optimization is task-specific
26
1. What is a Crosscutting Concern?
2. The Concern Mining Process and its Shortcomings
3. COMMIT
4. Case Study
5. Conclusion
27
28
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
28
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
28
Concern Mining Shortcomings
S1. limited seed context
S2. noise between seeds
S3. no composition of concerns
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
28
Concern Mining Shortcomings
S1. limited seed context
S2. noise between seeds
S3. no composition of concerns
COMMIT
CVS
transactions
function call or variable access added
intentional co-addition of calls and
accesses
concernseed
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
28
COMMIT complementsCBFA and HAM
CBFA HAM
COMMIT
0 0 1
08
14
9
CBFA HAM
COMMIT
1 0 0
09
14
9
Concern Mining Shortcomings
S1. limited seed context
S2. noise between seeds
S3. no composition of concerns
COMMIT
CVS
transactions
function call or variable access added
intentional co-addition of calls and
accesses
concernseed
QUESTIONS?
CrosscuttingConcerns
multi-threading
tracingexception
handling
data
persistence
security
memory
cleanup
3D rendering
performance
soundsupport
28
COMMIT complementsCBFA and HAM
CBFA HAM
COMMIT
0 0 1
08
14
9
CBFA HAM
COMMIT
1 0 0
09
14
9
Concern Mining Shortcomings
S1. limited seed context
S2. noise between seeds
S3. no composition of concerns
COMMIT
CVS
transactions
function call or variable access added
intentional co-addition of calls and
accesses
concernseed