Kerievsky`s Constructor Refactoring – An Empirical Study
Download
Report
Transcript Kerievsky`s Constructor Refactoring – An Empirical Study
Kerievsky’s Constructor Refactoring –
An Empirical Study
Research questions:
Do developers add constructors to OO classes Willy-nilly without
any regard for constructors already there?
Do comment lines tend to surround poorly written code?
What savings can be made through refactoring?
Kerievsky’s Catalog of Refactoring to Patterns
‘Replace Multiple Constructors with Creation Methods’
Eliminates code duplication inside constructors
Makes the class more maintainable because the methods are
named more appropriately
1
What did we do?
Manually collected all classes with three or more
constructors from 10 systems (five Java and five
C++ of different application domains)
140
identified from the five Java systems
For each class, simulated the removal of constructors
and lines of code saved as a result
Counted the number of comment lines removed as a
result
Results:
2
Results:
~ 400 lines of duplicated code removed across three of
the Java systems
~ 1250 lines of comments removed from the same three
systems (incidentally, were the worst written systems)
Two of the Java systems showed little or no opportunity
for refactoring (the best written systems)
Improved comprehensibility of the classes involved(?)
C++ systems virtually no opportunity for the same
refactoring (friends? No interfaces?)
3
Thanks for listening!
4