SlideShare a Scribd company logo
CODE SMELL/ BAD SMELL
CODE SMELL/ BAD SMELL
Anshul
National institute of Technology ,Kurukshetra
April 10, 2016
CODE SMELL/ BAD SMELL
Overview
1 Motivation
2 Introduction
Definition
Code re-factoring
3 Types of Code Smell
Duplicate Code
Long method
Large Class
Divergent Change
Shortgun Surgery
Feature Envy
Data Clumps
Comments
4 Advanced....
Two Level Dynamic Approach for Feature Envy Detection
5 Conclusion
CODE SMELL/ BAD SMELL
Motivation
Though Re-factoring is a old concept, developers are not
utilizing it.
To capture and write down the situation which make sense to
re-factoring.
Re factoring is directly related to Economics
CODE SMELL/ BAD SMELL
Introduction
Definition
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.
Such design flaw that can be solved by re-factoring.
According to MARTIN FOWLER ”IF it stinks change it.”
CODE SMELL/ BAD SMELL
Introduction
Code re-factoring
”Refactoring is the process of changing a software system in
such a way that it does not alter the external behavior of the
code yet improves its internal structure.
Refactoring is a form of program transformation which
preserves the semantics of the program.
Improving the design after it has been written.
It is an iterative process.
CODE SMELL/ BAD SMELL
Types of Code Smell
Duplicate Code
Occurrence of Same code structure more than once.
When we have same expression in two or more methods of
same class.
Solution for this code smell is to do Extract method and
then invoke the code from both the places.
CODE SMELL/ BAD SMELL
Types of Code Smell
Duplicate Code
Example 1
extern int a[];
extern int b[];
int sumofa = 0;
for (int i = 0; i < 4; i + +)
sum += a[i];
int averageofa= sum/4;
—————-
int sumofb = 0;
for (int i = 0; i < 4; i + +)
sum += b[i];
int averageofb = sumofb/4;
Extract method
int calc-average(int* array)
int sum= 0;
for (int i = 0; i < 4; i + +)
sum + =array[i];
return sum/4;
CODE SMELL/ BAD SMELL
Types of Code Smell
Duplicate Code
Example1 contd...
Extract method will give source code that has no loop duplication
extern int a[];
extern int b[];
int averageofa = calcAverage(a[]);
int averageofb = calcAverage(b[]);
CODE SMELL/ BAD SMELL
Types of Code Smell
Duplicate Code
Example 2
Another problem is when we have same code in two
subclasses.
Solution:-(Extract method + pull up method ) extract
similar codes from both the classes in form a method and
then put this method in the superclass.
CODE SMELL/ BAD SMELL
Types of Code Smell
Long method
Brief
Analysis and the experience says that the object programs
which lives best and longest are those with short methods.
To shorten a method all we have to do is to Extract a new
method
CODE SMELL/ BAD SMELL
Types of Code Smell
Long method
Key points:
IF method has a lot of parameters and variables , then these
things comes in the form of obstacles to Extract method.
Even if we try to do so , we will end up passing so many
parameters and variables to newly Extracted method.
Solution is to replace temp with query to eliminate temps.
And to slim down the long parameters we may introduce a
new parameter object And then preserving whole object.
CODE SMELL/ BAD SMELL
Types of Code Smell
Long method
Replace temp with Query
double basePrice
= quantity ∗ itemPrice;
if (basePrice > 1000)
return basePrice ∗ 0.95;
else return basePrice ∗ 0.98;
if (basePrice() > 1000) return
basePrice() ∗ 0.95;
else return basePrice() ∗ 0.98;
...———————
double basePrice()
return quantity ∗ itemPrice;
CODE SMELL/ BAD SMELL
Types of Code Smell
Long method
New Parameter Object
CODE SMELL/ BAD SMELL
Types of Code Smell
Long method
Question: How to decide the clumps of code that we
want to extract ?
CODE SMELL/ BAD SMELL
Types of Code Smell
Long method
Answer see comments ” . Even a single line is worth
extracting if it needs explanations.
CODE SMELL/ BAD SMELL
Types of Code Smell
Large Class
1 Signs and symptoms:
When a single class is doing too much , it often shows up too
many variables and instances
OR can say ; A class having many fields/methods/lines of code
is called as LARGE CLASS.
2 Reasons for the Problem:
Classes usually start small. But over time, they get bloated as
the program grows.
Programmers usually find it mentally less taxing to place a
new feature in an existing class than to create a new class for
the feature.
3 Treatment
Extract Class helps if part of the behavior of the large class
can be spun off into a separate component.
Extract SubClass helps if part of the behavior of the large
class can be implemented in different ways or is used in rare
cases.
CODE SMELL/ BAD SMELL
Types of Code Smell
Large Class
Extract Class
CODE SMELL/ BAD SMELL
Types of Code Smell
Divergent Change
When we make a change,we want to be able to a single clear
point in the system and make the change.
And if you can not do this, you are smelling one of the two
closely related pungencies.
Divergent change occurs when one class is commonly changed
in different ways for different reasons.
Split up the behavior of the class viaExtract Class
Payoff
Improves code organization.
Reduces code duplication.
Simplifies support.
CODE SMELL/ BAD SMELL
Types of Code Smell
Divergent Change
Example:
class User
def full−name
”#{first − name}#{last −
name}”
end
def authorized?(action)
is−admin?
end
end
class User
class UserPresenter
<SimpleDelegator
def full−name
”#{first − name}#{last −
name}”
end
end
class ActionAuthorizer def
authorized?(action, user)
user.is−admin?
end
end
# nothing here?
end
CODE SMELL/ BAD SMELL
Types of Code Smell
Shortgun Surgery
Shortgun surgery is opposite to divergent change
This happens when, you want to make some kind of
change, you are forced to make a lot of changes to a lot
of different classes
And when changes are all over the place, they are hard to find
,and it’s easy to miss an important change
Use MOVE METHOD and MOVE FIELD to pull all the
changes to a single class.
CODE SMELL/ BAD SMELL
Types of Code Smell
Shortgun Surgery
Example:Move Method
class Project {
Person[] participants;
}
class Person
{
int id;
boolean participate(Project p)
{ for(int i = 0; i < p.
participants .length ; i + +) {
if (p.participants[i].id ==id)
return(true);
} return(false); } }
... if (x.participate(p)) ...
class Project {
Person[] participants;
boolean participate(Person x) {
for(int i= 0;
i<participants.length; i++){
if (participants[i].id == x.id)
return(true); }
return(false);
}
}
class Person
{int id;}
... if (p.participate(x)) ...
CODE SMELL/ BAD SMELL
Types of Code Smell
Shortgun Surgery
Example: Move Field
A field is, or will be, used by another class more than the class on
which it is defined.
CODE SMELL/ BAD SMELL
Types of Code Smell
Shortgun Surgery
Why ”Move Field”
Often fields are moved as part of the Extract Class technique
Deciding which class to leave the field in can be tough.
Here is our rule of thumb: put a field in the same place as the
methods that use it (or else where most of these methods are).
This rule will help in other cases when a field is simply located
in the wrong place.
CODE SMELL/ BAD SMELL
Types of Code Smell
Feature Envy
The whole point of objects is that; they are kind of technique
that package data with the processes used on that data.
When a method seems more interesting in a class, other than
the one in actually it is.
The most common of focus of envy is data
For example; we have a method that invokes half a dozen
getting methods on another object to calculate some value.
The indication is obvious that the methods wants to be
elsewhere, so we can simply use MOVE METHOD to give
the method ,its dream home.
We are reducing the coupling and enhancing the cohesion
CODE SMELL/ BAD SMELL
Types of Code Smell
Feature Envy
Move method
CODE SMELL/ BAD SMELL
Types of Code Smell
Data Clumps
Data items enjoy hanging around in groups together.
Often we see the same three or four data items together in
lots of places like : fields in a couple of classes, parameters in
method signatures
These bunches of data ought to be made into their own object
Then apply Introduce parameter Object re-factoring ”
CODE SMELL/ BAD SMELL
Types of Code Smell
Comments
Comments are not bad smell.
Author has named them a Sweet Smell
When you feel the need to write comment,first try to re-factor
the code so that any comment becomes superfluous.
Comments are often used as Deodorant to the bad smell.
For example if we need a comment to explain what a block of
code does; try Extract method,if extract method is already
done , then Rename Method.
The purpose of Comments should be only ”Why you are
Doing Something(To help future modifiers)” rather than
”What code is doing ”
CODE SMELL/ BAD SMELL
Advanced....
Two Level Dynamic
Approach for Feature Envy
Detection
CODE SMELL/ BAD SMELL
Advanced....
Two Level Dynamic Approach for Feature Envy Detection
To refactor the code, it must be known which part of code
needs to be refactored.
For this purpose code smells are used.
In this field dynamic analysis is still in dark, which is an
opportunity to explore in this direction also.
To tackle this problem, we have devised a two level
mechanism
. First level filters out the methods which are suspects of being
feature envious
Second level analyzes those suspects to identify the actual
culprits.
CODE SMELL/ BAD SMELL
Advanced....
Two Level Dynamic Approach for Feature Envy Detection
Advantage Over Static Techniques
Static Techniques analyze the source code statically, which
is less accurate in object oriented environment.
The detection mechanism is applied over complete code
blindly, irrespective of whether they are completely free of any
kind of smell or not, which is an overhead
Dynamic analysis is a technique that analyzes the data
gathered during program executions , instead of analysing its
source code.
By executing a program, we can obtain an actual program
behaviour , which cannot be obtained from only analysing its
source code.
CODE SMELL/ BAD SMELL
Advanced....
Two Level Dynamic Approach for Feature Envy Detection
Purposed Work
CODE SMELL/ BAD SMELL
Advanced....
Two Level Dynamic Approach for Feature Envy Detection
Working of feature envy detection mechanism
CODE SMELL/ BAD SMELL
Conclusion
Conclusion
Code Smell detection is a challenging task.
it can be said that use of dynamic analysis can be
advantageous in detection of other types of code smells also
and will be a useful and efficient approach for software
maintainers.
CODE SMELL/ BAD SMELL
References
References
1 M. Fowler, K. Beck, J. Brant, W. Opdyke, and D. Roberts,
Refactoring: Improving the Design of Existing Code.
Addison-Wesley, 1999.
Swati, Jitender Kumar Chhabra,Two Level Dynamic Approach
for Feature Envy Detection;ICCCT [2014].
https://www.youtube.com/watch?v=vqEg37e4Mkw; a
seminar by Martin Fowler on ”Workflows of Refactoring”
CODE SMELL/ BAD SMELL
References
Thank you !

More Related Content

PPTX
Code smells and remedies
PDF
Bad Code Smells
KEY
Clean code and Code Smells
PPTX
Typescript ppt
PPTX
Code smell overview
PPTX
Robot Framework
PPT
Code Quality
DOC
Sales and inventory management system project report
Code smells and remedies
Bad Code Smells
Clean code and Code Smells
Typescript ppt
Code smell overview
Robot Framework
Code Quality
Sales and inventory management system project report

What's hot (20)

PPTX
PPTX
Refactoring and code smells
PPTX
Code refactoring
PPTX
clean code book summary - uncle bob - English version
PPTX
Clean code
PDF
PDF
Clean code
PPT
Clean code
PPTX
Clean code
PPT
Collection Framework in java
PPTX
[OOP - Lec 18] Static Data Member
PPT
Refactoring Tips by Martin Fowler
PPT
SOLID Design Principles
PPTX
Clean code slide
PDF
Javapolymorphism
PDF
Refactoring
PPTX
Code Smell, Software Engineering
PPTX
Software Craftsmanship - Code Smells - Dispensables
PPTX
Coding standards for java
PPTX
Flask – Python
Refactoring and code smells
Code refactoring
clean code book summary - uncle bob - English version
Clean code
Clean code
Clean code
Clean code
Collection Framework in java
[OOP - Lec 18] Static Data Member
Refactoring Tips by Martin Fowler
SOLID Design Principles
Clean code slide
Javapolymorphism
Refactoring
Code Smell, Software Engineering
Software Craftsmanship - Code Smells - Dispensables
Coding standards for java
Flask – Python
Ad

Similar to Code Smells and Its type (With Example) (20)

PPTX
Code smells quality of code
PPTX
Code Metrics
PPTX
Clean code
PPTX
06 java methods
ODP
Clean Code - Part 2
PDF
Refactoring: Improve the design of existing code
KEY
Anti-Patterns
PPTX
Clean code - DSC DYPCOE
PDF
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
PDF
PPTX
Code smell &amp; refactoring
PPT
TDD And Refactoring
PPTX
Pairwise testing technique-Made easy
PPTX
C# coding standards, good programming principles & refactoring
PPTX
Baroda code smell and refactoring
PDF
Unit testing - A&BP CC
PPTX
Agile korea 2013 유석문
PPTX
Stop fearing legacy code
PPTX
Principled And Clean Coding
PDF
Ddc2011 효과적으로레거시코드다루기
Code smells quality of code
Code Metrics
Clean code
06 java methods
Clean Code - Part 2
Refactoring: Improve the design of existing code
Anti-Patterns
Clean code - DSC DYPCOE
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
Code smell &amp; refactoring
TDD And Refactoring
Pairwise testing technique-Made easy
C# coding standards, good programming principles & refactoring
Baroda code smell and refactoring
Unit testing - A&BP CC
Agile korea 2013 유석문
Stop fearing legacy code
Principled And Clean Coding
Ddc2011 효과적으로레거시코드다루기
Ad

Recently uploaded (20)

PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
additive manufacturing of ss316l using mig welding
PPT
Mechanical Engineering MATERIALS Selection
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
composite construction of structures.pdf
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Sustainable Sites - Green Building Construction
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Well-logging-methods_new................
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
web development for engineering and engineering
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
additive manufacturing of ss316l using mig welding
Mechanical Engineering MATERIALS Selection
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Operating System & Kernel Study Guide-1 - converted.pdf
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
composite construction of structures.pdf
Internet of Things (IOT) - A guide to understanding
Sustainable Sites - Green Building Construction
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Well-logging-methods_new................
Lesson 3_Tessellation.pptx finite Mathematics
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
bas. eng. economics group 4 presentation 1.pptx
web development for engineering and engineering
UNIT-1 - COAL BASED THERMAL POWER PLANTS

Code Smells and Its type (With Example)

  • 1. CODE SMELL/ BAD SMELL CODE SMELL/ BAD SMELL Anshul National institute of Technology ,Kurukshetra April 10, 2016
  • 2. CODE SMELL/ BAD SMELL Overview 1 Motivation 2 Introduction Definition Code re-factoring 3 Types of Code Smell Duplicate Code Long method Large Class Divergent Change Shortgun Surgery Feature Envy Data Clumps Comments 4 Advanced.... Two Level Dynamic Approach for Feature Envy Detection 5 Conclusion
  • 3. CODE SMELL/ BAD SMELL Motivation Though Re-factoring is a old concept, developers are not utilizing it. To capture and write down the situation which make sense to re-factoring. Re factoring is directly related to Economics
  • 4. CODE SMELL/ BAD SMELL Introduction Definition 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. Such design flaw that can be solved by re-factoring. According to MARTIN FOWLER ”IF it stinks change it.”
  • 5. CODE SMELL/ BAD SMELL Introduction Code re-factoring ”Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure. Refactoring is a form of program transformation which preserves the semantics of the program. Improving the design after it has been written. It is an iterative process.
  • 6. CODE SMELL/ BAD SMELL Types of Code Smell Duplicate Code Occurrence of Same code structure more than once. When we have same expression in two or more methods of same class. Solution for this code smell is to do Extract method and then invoke the code from both the places.
  • 7. CODE SMELL/ BAD SMELL Types of Code Smell Duplicate Code Example 1 extern int a[]; extern int b[]; int sumofa = 0; for (int i = 0; i < 4; i + +) sum += a[i]; int averageofa= sum/4; —————- int sumofb = 0; for (int i = 0; i < 4; i + +) sum += b[i]; int averageofb = sumofb/4; Extract method int calc-average(int* array) int sum= 0; for (int i = 0; i < 4; i + +) sum + =array[i]; return sum/4;
  • 8. CODE SMELL/ BAD SMELL Types of Code Smell Duplicate Code Example1 contd... Extract method will give source code that has no loop duplication extern int a[]; extern int b[]; int averageofa = calcAverage(a[]); int averageofb = calcAverage(b[]);
  • 9. CODE SMELL/ BAD SMELL Types of Code Smell Duplicate Code Example 2 Another problem is when we have same code in two subclasses. Solution:-(Extract method + pull up method ) extract similar codes from both the classes in form a method and then put this method in the superclass.
  • 10. CODE SMELL/ BAD SMELL Types of Code Smell Long method Brief Analysis and the experience says that the object programs which lives best and longest are those with short methods. To shorten a method all we have to do is to Extract a new method
  • 11. CODE SMELL/ BAD SMELL Types of Code Smell Long method Key points: IF method has a lot of parameters and variables , then these things comes in the form of obstacles to Extract method. Even if we try to do so , we will end up passing so many parameters and variables to newly Extracted method. Solution is to replace temp with query to eliminate temps. And to slim down the long parameters we may introduce a new parameter object And then preserving whole object.
  • 12. CODE SMELL/ BAD SMELL Types of Code Smell Long method Replace temp with Query double basePrice = quantity ∗ itemPrice; if (basePrice > 1000) return basePrice ∗ 0.95; else return basePrice ∗ 0.98; if (basePrice() > 1000) return basePrice() ∗ 0.95; else return basePrice() ∗ 0.98; ...——————— double basePrice() return quantity ∗ itemPrice;
  • 13. CODE SMELL/ BAD SMELL Types of Code Smell Long method New Parameter Object
  • 14. CODE SMELL/ BAD SMELL Types of Code Smell Long method Question: How to decide the clumps of code that we want to extract ?
  • 15. CODE SMELL/ BAD SMELL Types of Code Smell Long method Answer see comments ” . Even a single line is worth extracting if it needs explanations.
  • 16. CODE SMELL/ BAD SMELL Types of Code Smell Large Class 1 Signs and symptoms: When a single class is doing too much , it often shows up too many variables and instances OR can say ; A class having many fields/methods/lines of code is called as LARGE CLASS. 2 Reasons for the Problem: Classes usually start small. But over time, they get bloated as the program grows. Programmers usually find it mentally less taxing to place a new feature in an existing class than to create a new class for the feature. 3 Treatment Extract Class helps if part of the behavior of the large class can be spun off into a separate component. Extract SubClass helps if part of the behavior of the large class can be implemented in different ways or is used in rare cases.
  • 17. CODE SMELL/ BAD SMELL Types of Code Smell Large Class Extract Class
  • 18. CODE SMELL/ BAD SMELL Types of Code Smell Divergent Change When we make a change,we want to be able to a single clear point in the system and make the change. And if you can not do this, you are smelling one of the two closely related pungencies. Divergent change occurs when one class is commonly changed in different ways for different reasons. Split up the behavior of the class viaExtract Class Payoff Improves code organization. Reduces code duplication. Simplifies support.
  • 19. CODE SMELL/ BAD SMELL Types of Code Smell Divergent Change Example: class User def full−name ”#{first − name}#{last − name}” end def authorized?(action) is−admin? end end class User class UserPresenter <SimpleDelegator def full−name ”#{first − name}#{last − name}” end end class ActionAuthorizer def authorized?(action, user) user.is−admin? end end # nothing here? end
  • 20. CODE SMELL/ BAD SMELL Types of Code Smell Shortgun Surgery Shortgun surgery is opposite to divergent change This happens when, you want to make some kind of change, you are forced to make a lot of changes to a lot of different classes And when changes are all over the place, they are hard to find ,and it’s easy to miss an important change Use MOVE METHOD and MOVE FIELD to pull all the changes to a single class.
  • 21. CODE SMELL/ BAD SMELL Types of Code Smell Shortgun Surgery Example:Move Method class Project { Person[] participants; } class Person { int id; boolean participate(Project p) { for(int i = 0; i < p. participants .length ; i + +) { if (p.participants[i].id ==id) return(true); } return(false); } } ... if (x.participate(p)) ... class Project { Person[] participants; boolean participate(Person x) { for(int i= 0; i<participants.length; i++){ if (participants[i].id == x.id) return(true); } return(false); } } class Person {int id;} ... if (p.participate(x)) ...
  • 22. CODE SMELL/ BAD SMELL Types of Code Smell Shortgun Surgery Example: Move Field A field is, or will be, used by another class more than the class on which it is defined.
  • 23. CODE SMELL/ BAD SMELL Types of Code Smell Shortgun Surgery Why ”Move Field” Often fields are moved as part of the Extract Class technique Deciding which class to leave the field in can be tough. Here is our rule of thumb: put a field in the same place as the methods that use it (or else where most of these methods are). This rule will help in other cases when a field is simply located in the wrong place.
  • 24. CODE SMELL/ BAD SMELL Types of Code Smell Feature Envy The whole point of objects is that; they are kind of technique that package data with the processes used on that data. When a method seems more interesting in a class, other than the one in actually it is. The most common of focus of envy is data For example; we have a method that invokes half a dozen getting methods on another object to calculate some value. The indication is obvious that the methods wants to be elsewhere, so we can simply use MOVE METHOD to give the method ,its dream home. We are reducing the coupling and enhancing the cohesion
  • 25. CODE SMELL/ BAD SMELL Types of Code Smell Feature Envy Move method
  • 26. CODE SMELL/ BAD SMELL Types of Code Smell Data Clumps Data items enjoy hanging around in groups together. Often we see the same three or four data items together in lots of places like : fields in a couple of classes, parameters in method signatures These bunches of data ought to be made into their own object Then apply Introduce parameter Object re-factoring ”
  • 27. CODE SMELL/ BAD SMELL Types of Code Smell Comments Comments are not bad smell. Author has named them a Sweet Smell When you feel the need to write comment,first try to re-factor the code so that any comment becomes superfluous. Comments are often used as Deodorant to the bad smell. For example if we need a comment to explain what a block of code does; try Extract method,if extract method is already done , then Rename Method. The purpose of Comments should be only ”Why you are Doing Something(To help future modifiers)” rather than ”What code is doing ”
  • 28. CODE SMELL/ BAD SMELL Advanced.... Two Level Dynamic Approach for Feature Envy Detection
  • 29. CODE SMELL/ BAD SMELL Advanced.... Two Level Dynamic Approach for Feature Envy Detection To refactor the code, it must be known which part of code needs to be refactored. For this purpose code smells are used. In this field dynamic analysis is still in dark, which is an opportunity to explore in this direction also. To tackle this problem, we have devised a two level mechanism . First level filters out the methods which are suspects of being feature envious Second level analyzes those suspects to identify the actual culprits.
  • 30. CODE SMELL/ BAD SMELL Advanced.... Two Level Dynamic Approach for Feature Envy Detection Advantage Over Static Techniques Static Techniques analyze the source code statically, which is less accurate in object oriented environment. The detection mechanism is applied over complete code blindly, irrespective of whether they are completely free of any kind of smell or not, which is an overhead Dynamic analysis is a technique that analyzes the data gathered during program executions , instead of analysing its source code. By executing a program, we can obtain an actual program behaviour , which cannot be obtained from only analysing its source code.
  • 31. CODE SMELL/ BAD SMELL Advanced.... Two Level Dynamic Approach for Feature Envy Detection Purposed Work
  • 32. CODE SMELL/ BAD SMELL Advanced.... Two Level Dynamic Approach for Feature Envy Detection Working of feature envy detection mechanism
  • 33. CODE SMELL/ BAD SMELL Conclusion Conclusion Code Smell detection is a challenging task. it can be said that use of dynamic analysis can be advantageous in detection of other types of code smells also and will be a useful and efficient approach for software maintainers.
  • 34. CODE SMELL/ BAD SMELL References References 1 M. Fowler, K. Beck, J. Brant, W. Opdyke, and D. Roberts, Refactoring: Improving the Design of Existing Code. Addison-Wesley, 1999. Swati, Jitender Kumar Chhabra,Two Level Dynamic Approach for Feature Envy Detection;ICCCT [2014]. https://www.youtube.com/watch?v=vqEg37e4Mkw; a seminar by Martin Fowler on ”Workflows of Refactoring”
  • 35. CODE SMELL/ BAD SMELL References Thank you !