Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Refactoring Effect Estimation Based on Complexity Metrics Yoshiki Higo, Yoshihiro Matsumoto, Shinji Kusumoto, Katuro Inoue
33
Embed
Refactoring Effect Estimation Based on Complexity Metrics
Refactoring Effect Estimation Based on Complexity Metrics. Yoshiki Higo, Yoshihiro Matsumoto, Shinji Kusumoto, Katuro Inoue. What’s Refactoring?. A set of operations to improve internal attributes of a software system without changing the external behavior of it - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1
Refactoring Effect Estimation Based on Complexity Metrics
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 2
What’s Refactoring? A set of operations to improve internal attributes of
a software system without changing the external behavior of it
One of trenchant countermeasures to handle large-scale and complex software systems
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Refactoring operating procedure
1. Identify where the software should be refactored
2. Determine which refactoring should be applied to the identified place
3. Guarantee that the applied refactoring preserves the behavior
4. Apply the refactoring
5. Assess the effect of the refactoring on quality characteristics of the software
6. Maintain the consistency between the refactored program code and other software artifacts
3
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Refactoring requires costs
A refactoring requires a certain cost to be completedIts impact should justify the cost
4
It is difficult to precisely estimate the effect of refactorings on the early stage of the refactoring
Inappropriate refactorings may be performed instead of appropriate ones Inappropriate refactorings become software
systems less maintainable or require much cost to be completed
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Proposal Technique -Overview- We propose a method estimating refactoring effect
INPUT: refactorings that developers are going to perform
OUTPUT: effect estimation of each of the refactorings
The method estimates refactoring effect from the following viewpoints (by using CK metrics suite)How coupling between classes will change,How cohesion of each class will change,How inheritance relationships between classes
will change
5
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
CK Metrics Suite Measures complexity of object-oriented software [1]
6
Better indicator to estimate occurrences of faults than other metrics [2]
Inheritance DIT (Depth of Inheritance Tree)NOC (Number Of Children)
Coupling RFC (Response For a Class)CBO (Coupling Between Object-class)
Cohesion WMC (Weighted Method per Class)LCOM (Lack Of Cohesion Method)
[1] S. Chidamber and C. Kemerer. A metric suite for object-oriented design. IEEE Transactions on Software Engineering, 25(5):476–493, Jun 1994.[2] V. R. Basili, L. C. Briand, and W. L. Melo. A validation of object-oriented design metrics as quality indicators. IEEE Transactions on Software Engineering, 22(10):751–761, Oct 1996.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Proposal Technique
7
refactoring pattern
original structure
A
B
CD
revised structure
A
B’
C’D
program
DC
BA
・・・・・・
・・・
・・・
・・・
・・・
D
・・・・・・
・・・
・・・
・・・
・・・
C
・・・・・・
・・・
・・・
・・・
・・・
B
・・・・・・
・・・
・・・
・・・
・・・
A
LCOMFRCCBONOCDITWMC
metrics of the original structure
・・・・・・
・・・
・・・
・・・
・・・
D
・・・・・・
・・・
・・・
・・・
・・・
C’
・・・・・・
・・・
・・・
・・・
・・・
B’
・・・・・・
・・・
・・・
・・・
・・・
A
LCOMFRCCBONOCDITWMC
metrics of the revised structure
input
comparison result
output
STEP1 STEP2
STEP3
STEP4
STEP5
STEP6
STEP6
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Proposal Technique -STEP1-
The whole of the target program is parsed to construct a structure representing itThe structure includes all information required to
measure CK metrics8
output
refactoring pattern
original structure
A
B
CD
revised structure
A
B’
C’D
program
DC
BA
・・・・・・
・・・
・・・
・・・
・・・
D
・・・・・・
・・・
・・・
・・・
・・・
C
・・・・・・
・・・
・・・
・・・
・・・
B
・・・・・・
・・・
・・・
・・・
・・・
A
LCOMFRCCBONOCDITWMC
metrics of the original structure
・・・・・・
・・・
・・・
・・・
・・・
D
・・・・・・
・・・
・・・
・・・
・・・
C’
・・・・・・
・・・
・・・
・・・
・・・
B’
・・・・・・
・・・
・・・
・・・
・・・
A
LCOMFRCCBONOCDITWMC
metrics of the revised structure
input
comparison result
output
STEP1 STEP2
STEP3
STEP4
STEP5
STEP6
STEP6
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Proposal Technique -STEP2-
CK metrics are measured from the structureThese metrics represent the complexity of the original
program
9
refactoring pattern
original structure
A
B
CD
revised structure
A
B’
C’D
program
DC
BA
・・・・・・
・・・
・・・
・・・
・・・
D
・・・・・・
・・・
・・・
・・・
・・・
C
・・・・・・
・・・
・・・
・・・
・・・
B
・・・・・・
・・・
・・・
・・・
・・・
A
LCOMFRCCBONOCDITWMC
metrics of the original structure
・・・・・・
・・・
・・・
・・・
・・・
D
・・・・・・
・・・
・・・
・・・
・・・
C’
・・・・・・
・・・
・・・
・・・
・・・
B’
・・・・・・
・・・
・・・
・・・
・・・
A
LCOMFRCCBONOCDITWMC
metrics of the revised structure
input
comparison result
output
STEP1 STEP2
STEP3
STEP4
STEP5
STEP6
STEP6
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Proposal Technique -STEP3-
The refactorings that developers are going to perform are inputWhere of the target program is refactoredHow the part is refactored
10
refactoring pattern
original structure
A
B
CD
revised structure
A
B’
C’D
program
DC
BA
・・・・・・
・・・
・・・
・・・
・・・
D
・・・・・・
・・・
・・・
・・・
・・・
C
・・・・・・
・・・
・・・
・・・
・・・
B
・・・・・・
・・・
・・・
・・・
・・・
A
LCOMFRCCBONOCDITWMC
metrics of the original structure
・・・・・・
・・・
・・・
・・・
・・・
D
・・・・・・
・・・
・・・
・・・
・・・
C’
・・・・・・
・・・
・・・
・・・
・・・
B’
・・・・・・
・・・
・・・
・・・
・・・
A
LCOMFRCCBONOCDITWMC
metrics of the revised structure
input
comparison result
output
STEP1 STEP2
STEP3
STEP4
STEP5
STEP6
STEP6
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Proposal Technique -STEP4-
The structure is revised based on the refactorings input in STEP3
11
refactoring pattern
original structure
A
B
CD
revised structure
A
B’
C’D
program
DC
BA
・・・・・・
・・・
・・・
・・・
・・・
D
・・・・・・
・・・
・・・
・・・
・・・
C
・・・・・・
・・・
・・・
・・・
・・・
B
・・・・・・
・・・
・・・
・・・
・・・
A
LCOMFRCCBONOCDITWMC
metrics of the original structure
・・・・・・
・・・
・・・
・・・
・・・
D
・・・・・・
・・・
・・・
・・・
・・・
C’
・・・・・・
・・・
・・・
・・・
・・・
B’
・・・・・・
・・・
・・・
・・・
・・・
A
LCOMFRCCBONOCDITWMC
metrics of the revised structure
input
comparison result
output
STEP1 STEP2
STEP3
STEP4
STEP5
STEP6
STEP6
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
STEP4 It is impossible to fully-automatically revise the
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
A case study -Tool’s result-
All candidates will not change the change rates of metrics WMC, DIT, NOC, and LCOM
All candidates will have no or a little bit of change on metric RFC
CASE1 will be able to greatly reduce the change rate of metric CBO while all of other candidates will increase it.
CASE1 CASE2 CASE3 CASE4
WMC 0.0 0.0 0.0 0.0
DIT 0.0 0.0 0.0 0.0
NOC 0.0 0.0 0.0 0.0
CBO -1.90 1.67 3.03 0.60
RFC 0.18 0.09 0.40 0.00
LCOM 0.00 0.00 0.00 0.00
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
A case study -Tool’s result-
All candidates will not change the change rates of metrics WMC, DIT, NOC, and LCOM
All candidates will have no or a little bit of change on metric RFC
CASE1 will be able to greatly reduce the change rate of metric CBO while all of other candidates will increase it.
CASE1 CASE2 CASE3 CASE4
WMC 0.0 0.0 0.0 0.0
DIT 0.0 0.0 0.0 0.0
NOC 0.0 0.0 0.0 0.0
CBO -1.90 1.67 3.03 0.60
RFC 0.18 0.09 0.40 0.00
LCOM 0.00 0.00 0.00 0.00
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
A case study -Tool’s result-
All candidates will not change the change rates of metrics WMC, DIT, NOC, and LCOM
All candidates will have no or a little bit of change on metric RFC
CASE1 will be able to greatly reduce the change rate of metric CBO while all of other candidates will increase it.
CASE1 CASE2 CASE3 CASE4
WMC 0.0 0.0 0.0 0.0
DIT 0.0 0.0 0.0 0.0
NOC 0.0 0.0 0.0 0.0
CBO -1.90 1.67 3.03 0.60
RFC 0.18 0.09 0.40 0.00
LCOM 0.00 0.00 0.00 0.00
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
A case study -Tool’s result-
All candidates will not change the change rates of metrics WMC, DIT, NOC, and LCOM
All candidates will have no or a little bit of change on metric RFC
CASE1 will be able to greatly reduce the change rate of metric CBO while all of other candidates will increase it
CASE1 CASE2 CASE3 CASE4
WMC 0.0 0.0 0.0 0.0
DIT 0.0 0.0 0.0 0.0
NOC 0.0 0.0 0.0 0.0
CBO -1.90 1.67 3.03 0.60
RFC 0.18 0.09 0.40 0.00
LCOM 0.00 0.00 0.00 0.00
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
A case study -Master Student’s Decision- Before tool’s application
The master student selected CASE3He thought that class CL had a similar function to the
class of CASE3His decision was based on his instinct rather than
objective basis like bug information, software metrics, or design patterns
After tool’s applicationHe recognized that the tool’s estimation was better
than his own determination, and adopted the CASE1 refactoring
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
A case study -Measurement Precision- After the estimation, we actually performed each of
the 4 refactorings on the source code respectively CK metrics were measured from the refactored
source code, and change rates were calculated All of the metrics and change rates were the same
as ones measured from the revised bytecode
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Validity of the method No research has revealed obvious foundation that
good refactoring lead to lower CK measures
When a maintainer perform a refactoring, there is a obvious goal of it
The proposal technique enables the maintainer to know whether the goal can be accomplished or not
Side-effects of the refactoring can be represented by the change rateThe maintainer can avoid regretting the refactoring
after actually performing it
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Limitations -the case study- The examinee is a single master student
We need to conduct case studies involving more examinees, which consist of different level programmers
The target program size is not practical Only the change of complexity metrics values was
considered as the effects of refactorings
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Limitation -the case study- The examinee is a single master student The target program size is not practical
We need to conduct case studies on more practical size software systems
But, this case study revealed that it is difficult to perform effective refactorings on even a small-size program
Only the change of complexity metrics values was considered as the effects of refactorings
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Limitation -proposal technique- The examinee is a single master student The target program size is not practical Only the change of complexity metrics was
considered as the effects of refactoringsReal refactorings require source code modification
cost and regression test costIn order to estimate refactoring effectiveness more
precisely, we have to considerer those costs
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Conclusion and Future Works In this study, we
proposed a new technique to estimate refactoring effect
Implemented a software tool based on the proposalApplied it to a small software system
We are going to re-implement the tool for revising not bytecode but
source code, which can achieve automated source code modification
handle other refactoring patterns
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University