Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Â
Code Smell, Software Engineering
1. Prioritization of Smelly Classes
Based on Bad Smells
Supervised By
Dr. Jitender Kumar Chhabra
Presented By
Anshul Rani
(31503121)
2. INTRODUCTION
CODE REFACTORING
Refactoring is the process of changing a software system in such a way that it does not alter
the external behaviour of the code yet improves its internal structure.
Advantages
a) Code readability improvement
b) Complexity Reduction
c) Creates a more expressive internal structure to improve maintainability
3. Motivation
a) Though Re-factoring is a old concept, developers are not utilizing it.
b) To capture and write down the symptoms which make sense to re-factoring.
âIf it stinks change itâ [1]
CODE SMELL
Code smells are indications of poor coding and design choices that can cause problems during
the later phase of software development. Code smells are considered as flags to the developer
that some parts of the design may be inappropriate. [1]
There are 22 types of smells identified in [1]. For example Duplicate Code, Feature envy,
Divergent Change, Shotgun Surgery etc.
[1] M. Fowler, K. Beck, J. Brant, W. Opdyke, and D. Roberts, âRefactoring Improving the Design of Existing Codeâ,
Addison-Wesley, 1999.
INTRODUCTION: CODE SMELL
4. PROBLEM DESCRIPTION
CODE SMELL
DETECTION [4,5,11] PRIORITIZATION
STATIC [6,12] DYNAMIC [3] INTER SMELL
RELATION
STATIC [2] DYNAMIC [7,8]
[3] Fabio Palomba, Gabriele Bavota and Rocco Oliveto âMining Version Histories for Detecting Code Smellsâ,
Software Engineering, IEEE transactions on , vol 41, no 5, pp 462-489, 2015, IEEE.
[5] Min Zhang,Tracy Hall and Nathan Baddoo , âCode Bad Smells: a review of current knowledgeâ Journal of
Software Maintenance and evolution, research and practice, Vol 23,pp-179â202 , 2011,Wiley Online Library.
[7] Pietrzak B and Walter B. âExploring Bad Smells Dependenciesâ, In Zielinski K., Conference on Extreme Programming
and Agile, Vol. 130, pp. 353-364, 2006,Springer.
[12] Naoul Moha ,Yann-Gael Gueheneue and Anne-F. Lee, â DĂCOR: A Method for the Specification and Detection of
Code and Design Smells â IEEE Transactions on Software Engg. , Vol 36 ,pp-20-35,2010,IEEE
5. PROBLEM DESCRIPTION
[14] M. Abbes, F. Khomh, Y-G. Gueheneuc, and G. Antoniol, âAn empirical study of impact of two antipatterns, blob and
spaghetti code, on program comprehensionâ, in 15th European Conference on Software Maintenance and Reengineering,
pp.181-190, 2011.
ď Code Smells results into a poor system design, thus need to be corrected for which
refactoring is one of the possible solutions.[14]
ď It is desirable to make an efficient approach of refactoring.
ď Such approach that can smartly select that which classes actually need refactoring; and
can tell a sequence in which smelly classes should be refactored.
ď It includes extra time, efforts and even sometimes implementation of one refactoring
mechanism may include several other refactorings to be implemented, therefore forming
refactoring chains [10].
[10] H. Hamza, S. Counsell, G. Loizou and T. Hall, âCode Smell Eradication and Associated Refactoringâ, in proceedings
of the European Computing Conference (ECC), Malta, pp.102-107, September, 2008..
6. RELATED WORK
[9] R. Wongpiang and P. Muenchaisri, "Selecting Sequence of Refactoring Techniques Usage for Code Changing Using
Greed Algorithm", Electronics Information and Emergency Communication (ICEIEC) 4th International Conference, pp.
160-164, 2013, IEEE.
ď To get Optimal maintainability, authors find out possible sequences of
refactoring maintainability. [9]
ď In their study they suggested a Greedy algorithm to find out the optimal
refactoring sequence among all the possible sequences of the refactoring.
ď Study primarily focuses on the possible refactorings of Long Method, Long Class
and Feature Envy
7. RELATED WORK
[13] Aiko Yamashita , Leon Moonen,âExploring the impact of inter smell relations on software Maintainability: An
Empirical Studyâ,Proc of the international Conf on Software engg , pp-682-691,2013, ACM.
[15] Steffen M. Olbrich, Daniela S.Cruzes, Dag I.K. Sjoberg, âAre all Code Smells Harmful ? A study of God Classes and
Brain Classes in the Evolution of three Open Source Systemsâ, 26th IEEE International Conference on Software
Maintenance,pp. 1-10, 2010.
ď Yamashita et al. [13] suggested that not only code smells, but interaction between
code smells also affect maintenance.
ď As all the code smells are not equally harmful, some of them are not at all effective
[15].
ď Though refactoring indulges extra efforts and time, thus it is necessary to understand
the relationship between code smells, so that proper attention and time can be given to
appropriate smells.
ď As of study results they found some inter dependencies between different code smells.
ď They also concluded that these dependencies may vary in different scenarios.
8. RELATED WORK
[8] Angela Lonzano, Kim Mens and Jawia Portugal âAnalyzing Code Evolution to Uncover Relation between Bad Smellsâ
International Confrence on Analysis, Evolution and Reengineering, pp.1-4, 2015.
[7] Pietrzak B and Walter B. âExploring Bad Smells Dependenciesâ, In Zielinski K., Conference on Extreme
Programming and Agile, Vol. 130, pp. 353-364, 2006,Springer.
ď Angela et al. discovered the co-relation among four different smells named God Class,
Long Method and Feature Envy [8].
ď For this purpose they mined Change History of the software.
ď Piterzak et al. Also found inter smell relations but using multiple aspects [7].
ď Multiple aspects includes programmer intuition and experience, Metrics value, Dynamic
behavior of code and Change History mining too.
10. CHANGE
HISTORY
(MINE ONLY
SMELLY
CLASSES)
SOURCE CODE
SMELLY INSTANCES/CLASSES
DETECTION OF BAD SMELLS
DETECTIONPHASE
PRIORITIZE SMELLY CLASSES
IMPACT INDEX MEASUREMENT
PRIORITIZATIONPHASE
CURRENT STATUS OF WORK
APPLY REFRACTORING
REFACTORED CODE
11. CURRENT STATUS OF WORK
Detection Phase-
ď We have used JDeodorant [18](Eclipse plug-in) for detection of smelly classes which mainly
detects five sorts of smells specifically feature envy, Duplicate code, Long Method, God
Class.
Prioritization Phase-
ď Change history of smelly classes (found in first phase) is mined.
ď Change reports are mined for identifying the interactions of smelly class with other classes
of system. Interaction of a class with other classes indicates coupling of the class with rest of
the system.
ď Based on the impact, a prioritization list of classes is being constructed, smelly instance,
having more impact is considered more severe, so it is put first in prioritization list.
ď Prioritization list tells the order in which refactoring should be performed.
ď Thus by using prioritization list, we firstly refactor more severe smelly classes.
couplingspossible
withcoupledisitclassesofnumber
classaofindeximpact ď˝
12. CURRENT STATUS OF WORK
0
10
20
30
40
50
60
70
80
90
100
1 2 3 4 5 6 7 8 9 10
CodeSmellsLeft(%)
No_of_Refactoring_Performed
Refactoring using Prioritization Random Refactoring
ď We have evaluated our proposed approach
over a project named
HospitalAutomationWithJavaEE [19]
ď Project has 49 classes and 58 commits
recorded for it
ď Refactoring using prioritization left
only 21% code smells in the system
whereas random refactoring left 50%
code smells in the system (after 10 time
refactoring)
13. CONCLUSION
ď Frequent changes in an object-oriented software system often result into a poor-quality and
less maintainable design
ď The symptoms (known as Code Smells) causing that degradation, need to be corrected for
which refactoring is one of the possible solutions.
ď It is not feasible to refactor/ restructure each and every smelly class due to various
constraints such as time and cost.
ď It is desirable to make an efficient approach of refactoring.
ď Proposed scheme aims to save time (and cost) of refactoring by carrying out selective
refactoring for high priority smelly classes.
ď Prioritization is proposed to be done according to interaction level of each class with other
classes.
14. FUTURE WORK
ď We are analyzing different code smells over various parameters like complexity,
refactoring time, measurement factor etc.
ď Along with that we are exploring inter-dependencies between different smells,
ď Using these two aspects we will prioritize the code smells, and will provide an
ordering in which code smells should be removed.
15. [1] M. Fowler, K. Beck, J. Brant, W. Opdyke, and D. Roberts, âRefactoring Improving the Design of Existing Codeâ
Addison-Wesley, 1999
[2] F. A. Fontana, V. Feme, and M. Zanoni, âTowards a Prioritization of Code Debt : A Code Smell Intensity Index â, In
Proc. Of IEEE 7th International workshop on Managing Technical Debt, 2015. pp 16-24, 2015, IEEE.
[3] Fabio Palomba, Gabriele Bavota and Rocco Oliveto âMining Version Histories for Detecting Code Smellsâ,
Software Engineering, IEEE transactions on , vol 41, no 5, pp 462-489, 2015, IEEE.
[4] T. Mens and T. Tourwe, A Survey of Software Refactoring, IEEE Transactions on Software Engineering 30(2):
pp-126--139 ,2004, IEEE.
[5] Min Zhang,Tracy Hall and Nathan Baddoo , âCode Bad Smells: a review of current knowledgeâ Journal of
Software Maintenance and evolution, research and practice, Vol 23,pp-179â202 , 2011,Wiley Online Library.
[6] A. Rao, K.Reddy, âDetecting Bad Smells in Object Oriented Design using Design Change Propagation Probability
matrixâ In proc. of IMECS(International Multiconference of engineers and Computer Scientist),Vol 1, pp.19-21,
2008,IEEE.
[7] Pietrzak B and Walter B. âExploring Bad Smells Dependenciesâ, In Zielinski K., Conference on Extreme
Programming and Agile, Vol. 130, pp. 353-364, 2006,Springer.
[8] Angela Lonzano, Kim Mens and Jawia Portugal âAnalyzing Code Evolution to Uncover Relation between Bad
Smellsâ International Conference on Analysis, Evolution and Reengineering, pp.1-4, 2015.
[9] R. Wongpiang and P. Muenchaisri, "Selecting Sequence of Refactoring Techniques Usage for Code Changing
Using Greed Algorithm", Electronics Information and Emergency Communication (ICEIEC) 4th International
Conference pp. 160-164, 2013, IEEE.
[10] H. Hamza, S. Counsell, G. Loizou and T. Hall, âCode Smell Eradication and Associated Refactoringâ, in
proceedings of the European Computing Conference (ECC), Malta, pp.102-107, September, 2008.
REFERENCES
16. [11] Raed Shatnawi, Wei Li, âThe effectiveness of Software Metrics in Identifying Error Prone Classes in Post Release
Software Evolution Processâ, in the Journal of System and Software , Vol 81 , pp (1868-1882),2008, Science Direct.
[12] Naoul Moha ,Yann-Gael Gueheneue and Anne-F. Lee, â DĂCOR: A Method for the Specification and Detection of
Code and Design Smells â IEEE Transactions on Software Engineering, Vol 36, pp-20-35, 2010, IEEE .
[13] Aiko Yamashita , Leon Moonen,âExploring the Impact of Inter Smell Relations on Software Maintainability: An
Empirical Studyâ, In Proceedings of the International Conference on Software Engineering , pp-682-691,2013, ACM.
[14] M. Abbes, F. Khomh, Y-G. Gueheneuc, and G. Antoniol, âAn Empirical Study of Impact of Two Antipatterns, Blob and
Spaghetti Code, on Program Comprehensionâ, in 15th European Conference on Software Maintenance and
Reengineering, pp.181-190, 2011.
[15] Steffen M. Olbrich, Daniela S.Cruzes, Dag I.K. Sjoberg, âAre all Code Smells Harmful ? A study of God Classes and
Brain Classes in the Evolution of three Open Source Systemsâ, 26th International Conference on Software
Maintenance, pp. 1-10, 2010, IEEE.
[16] A.Yamashita, âAssessing the Capability of Code Smells to Support Software Maintainability Assessment:
Empirical Inquiry and Methodological Approachâ, Doctoral Thesis, University of Oslo, 2012.
[17] Aiko Yamashita, Marco Zanoni, Francesca Arcelli Fontana and Bartosz Walter, âInter-Smell Relations in Industrial
and Open Source Systems: A Replication and Comparative Analysisâ, International Conference on Software
Maintenance and Evolution, Bremen Germany, pp- 121-130, 2015.
[18] Marios Fakaefs, Nikolaos Tsantalis and Alexander Chatzigeorgiou, âJDeodorant: Identification and removal of
Feature Envy Bad Smellsâ, IEEE International Conference on Soft Materials, pp.519-520, 2007.
[19] https://github.com/ilkgunel/HospitalAutomationWithJavaEE.
[20] Anshu Parashar, Jitender kumar Chhabra, âMeasuring Change- Readiness of Classes by Mining Change-History
â, ACM SIGSOFT Software Engineering Notes, Vol 39, Issue 6, pp.1-60, 2014.
REFERENCES