際際滷

際際滷Share a Scribd company logo
Code Smell
Quality Of Code
Question
1. What is Bug?
Introduction
Code smells are not bugs or errors. Instead, these are absolute violations of the fundamentals of developing
software that decrease the quality of code.
Having code smells does not certainly mean that the software wont work, it would still give an output, but it
may slow down processing, increased risk of failure and errors while making the program vulnerable to bugs
in the future. Smelly code contributes to poor code quality and hence increasing the technical debt.
Any fool can write code that a computer can understand,
good programmers write code that every human can
understand. - Martin Fowler
Code Smell Example
Comments
Are Comments necessary?
1. Why?
2. What?
3. Comments are for people not for
machines.
4. Think about refactoring the code so
that comments are not needed.
Long Method
Try avoiding longer methods.
Short methods are easier to read &
understand for a developer who
looks at the code.
1. Ideal lines of code -20.
2. Methods with 5 lines of code,
indicate that you are breaking
up the code too much, making
it harder to understand,
Code Smell Example (Cont.)
Too Many Parameters
Avoid to many parameters in the
method signature.
1. Ideal number of parameters (as
per checkstyle static code
analyzer) -7
2. Keeping it less than 5 makes it
easy to read understand.
Type Embedded in Name
Avoid embedding types to the
variable names.
Some Bad Example
1. List<String> listofStudents;
2. String sStudent;
3. Int iAmmount
Code Smell Example (Cont.)
Inconsistent Names
Many developers have trouble with
naming the methods with the efficient
name.
Examples
1. Use lower case for packages.
2. Use camel case of variables and
method names.
3. Avoid using _
Dead Code
Unused code? Or commented
code? Delete is before push to
repository.
Code Smell Example (Cont.)
Solution Sprawl
If you have too many classes to
perform a solution, you might have
solution sprawl.
Time to refactor the code.
Application Level Smells
1. Duplicate Code - Similar code in more than
one location.
2. Shotgun Surgery - One change requires
altering many different classes.
3. Contrived Complexity - Using complex
design patterns where a simpler
uncomplicated design could be used.
Class Level Smells
1. Large Class - Class trying to do too much and has too many
instance variables.
2. Freeloader - Class doing too little
3. Feature Envy - Class with a method that seems more interested in
other class than the one it is in.
4. Divergent Code - A class that suffers many kinds of changes to
bring a change in a system.
5. Data Clump - Bunches of data that clump together in lots of
places.
6. Inappropriate Intimacy - A class that has dependencies on
implementation details of other class.
7. Middle Man - Class with lots of methods delegated to other class.
8. Downcasting - Typecast that breaks the abstraction model.
9. Parallel Inheritance Hierarchy - Every time you make a subclass
for a single class, you are needed to make subclass.
10. Refused Bequest - Subclass not using methods and data of
superclass.
11. Cyclomatic Complexity - Class with too many branches and
loops.
Method Level Smells
1. Long Method - Long procedures that are hard to
understand.
2. Speculative Generality - Methods whose only users
are test cases.
3. Message Chains - Method calling a different method
which calls a different method which calls a different
method and on and on.
4. Too Many Parameters - A very long list of
parameters.
5. Oddball Solutions - When multiple methods are
used to solve the same problem in one program
creating inconsistency.
6. God Line - An excessively long line of code.
7. Excessive Returner - A method that returns more
data than what its caller needs.
8. Identifier Size - The identifier is excessively short or
long.
Ad

Recommended

Code sense
Code sense
nasirj
7 rules on code readability
7 rules on code readability
Per Lundholm
Mca2030 object oriented programming c++
Mca2030 object oriented programming c++
smumbahelp
Coding standards
Coding standards
BishalAryal8
Robotics
Robotics
Muhammed Aly
How to code
How to code
Shishir Sharma
Problem solving on acm international collegiate programming contest
Problem solving on acm international collegiate programming contest
Fedor Tsarev
Grade 11 CS Review (unit 1)
Grade 11 CS Review (unit 1)
kcardinale113
Ggg
Ggg
Chriselle24
Walmyr Filho - Lessons learned as software engineer working at appear.in
Walmyr Filho - Lessons learned as software engineer working at appear.in
Agile Lietuva
Clean Code, Resumen Cap鱈tulo 1.
Clean Code, Resumen Cap鱈tulo 1.
Francisco Lopez Espinosa
Python lec 1002_for_biologists
Python lec 1002_for_biologists
Ramadan Babers, PhD
10 it python revision
10 it python revision
hccit
Bj淡rneg奪rd school visit @ Simuladagen 2015
Bj淡rneg奪rd school visit @ Simuladagen 2015
Phu H. Nguyen
Python lec 1001_for_biologists
Python lec 1001_for_biologists
Ramadan Babers, PhD
Coding Checkpoints
Coding Checkpoints
George Orhewere
Type Checking in Python at Tiqets
Type Checking in Python at Tiqets
scar Vilaplana
Ccl l6
Ccl l6
smit228
Clean Code - Part 2
Clean Code - Part 2
Knoldus Inc.
Ee java lab assignment 3
Ee java lab assignment 3
Kuntal Bhowmick
Adding gift questions in swayam 2.0
Adding gift questions in swayam 2.0
aschrdc
Multi threading 04 1_2021
Multi threading 04 1_2021
Sugnan M
Cs2 Ch1
Cs2 Ch1
Reynolds SD
Python programming
Python programming
noor_faiza
Compiler Design - Introduction to Compiler
Compiler Design - Introduction to Compiler
Iffat Anjum
Year 7 lesson 4 interactive and script mode
Year 7 lesson 4 interactive and script mode
tmoncrieff
[DevDay2018] Lets all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Lets all get along. Clean Code please! - By: Christophe K. Ngo,...
DevDay Da Nang
Bad Code Smells
Bad Code Smells
kim.mens
"PHP Code Avengers: Structuring, Refactoring, and Superhero Practices", Vlad...
"PHP Code Avengers: Structuring, Refactoring, and Superhero Practices", Vlad...
Fwdays
Code Smells Part 1: Basic Smells
Code Smells Part 1: Basic Smells
Nancy Henson

More Related Content

What's hot (18)

Ggg
Ggg
Chriselle24
Walmyr Filho - Lessons learned as software engineer working at appear.in
Walmyr Filho - Lessons learned as software engineer working at appear.in
Agile Lietuva
Clean Code, Resumen Cap鱈tulo 1.
Clean Code, Resumen Cap鱈tulo 1.
Francisco Lopez Espinosa
Python lec 1002_for_biologists
Python lec 1002_for_biologists
Ramadan Babers, PhD
10 it python revision
10 it python revision
hccit
Bj淡rneg奪rd school visit @ Simuladagen 2015
Bj淡rneg奪rd school visit @ Simuladagen 2015
Phu H. Nguyen
Python lec 1001_for_biologists
Python lec 1001_for_biologists
Ramadan Babers, PhD
Coding Checkpoints
Coding Checkpoints
George Orhewere
Type Checking in Python at Tiqets
Type Checking in Python at Tiqets
scar Vilaplana
Ccl l6
Ccl l6
smit228
Clean Code - Part 2
Clean Code - Part 2
Knoldus Inc.
Ee java lab assignment 3
Ee java lab assignment 3
Kuntal Bhowmick
Adding gift questions in swayam 2.0
Adding gift questions in swayam 2.0
aschrdc
Multi threading 04 1_2021
Multi threading 04 1_2021
Sugnan M
Cs2 Ch1
Cs2 Ch1
Reynolds SD
Python programming
Python programming
noor_faiza
Compiler Design - Introduction to Compiler
Compiler Design - Introduction to Compiler
Iffat Anjum
Year 7 lesson 4 interactive and script mode
Year 7 lesson 4 interactive and script mode
tmoncrieff
Walmyr Filho - Lessons learned as software engineer working at appear.in
Walmyr Filho - Lessons learned as software engineer working at appear.in
Agile Lietuva
Python lec 1002_for_biologists
Python lec 1002_for_biologists
Ramadan Babers, PhD
10 it python revision
10 it python revision
hccit
Bj淡rneg奪rd school visit @ Simuladagen 2015
Bj淡rneg奪rd school visit @ Simuladagen 2015
Phu H. Nguyen
Python lec 1001_for_biologists
Python lec 1001_for_biologists
Ramadan Babers, PhD
Type Checking in Python at Tiqets
Type Checking in Python at Tiqets
scar Vilaplana
Ccl l6
Ccl l6
smit228
Clean Code - Part 2
Clean Code - Part 2
Knoldus Inc.
Ee java lab assignment 3
Ee java lab assignment 3
Kuntal Bhowmick
Adding gift questions in swayam 2.0
Adding gift questions in swayam 2.0
aschrdc
Multi threading 04 1_2021
Multi threading 04 1_2021
Sugnan M
Python programming
Python programming
noor_faiza
Compiler Design - Introduction to Compiler
Compiler Design - Introduction to Compiler
Iffat Anjum
Year 7 lesson 4 interactive and script mode
Year 7 lesson 4 interactive and script mode
tmoncrieff

Similar to Code smells quality of code (20)

[DevDay2018] Lets all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Lets all get along. Clean Code please! - By: Christophe K. Ngo,...
DevDay Da Nang
Bad Code Smells
Bad Code Smells
kim.mens
"PHP Code Avengers: Structuring, Refactoring, and Superhero Practices", Vlad...
"PHP Code Avengers: Structuring, Refactoring, and Superhero Practices", Vlad...
Fwdays
Code Smells Part 1: Basic Smells
Code Smells Part 1: Basic Smells
Nancy Henson
OOPSCA1.pptx
OOPSCA1.pptx
Soumyadipchanda2
Code Smells and Its type (With Example)
Code Smells and Its type (With Example)
Anshul Vinayak
Code smell overview
Code smell overview
Pham Manh Lan
Clean code - DSC DYPCOE
Clean code - DSC DYPCOE
Patil Shreyas
Refactoring
Refactoring
Xavier Forn辿s Arrabal
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standards
Perfomatix Solutions
Selenium Design Patterns
Selenium Design Patterns
Liraz Shay
TDD Are you sure you properly test code?
TDD Are you sure you properly test code?
Dmitriy Nesteryuk
Mca2030 object oriented programming c++
Mca2030 object oriented programming c++
smumbahelp
Mca2030 object oriented programming c++
Mca2030 object oriented programming c++
smumbahelp
Clean Code
Clean Code
ssusera3d06b1
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Kaunas Java User Group
Code Smells - Refactoring
Code Smells - Refactoring
Shobi P P
Clean code: understanding Boundaries and Unit Tests
Clean code: understanding Boundaries and Unit Tests
radin reth
Clean Code
Clean Code
Chris Farrell
Code Smell and Refactoring
Code Smell and Refactoring
kimsrung lov
[DevDay2018] Lets all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Lets all get along. Clean Code please! - By: Christophe K. Ngo,...
DevDay Da Nang
Bad Code Smells
Bad Code Smells
kim.mens
"PHP Code Avengers: Structuring, Refactoring, and Superhero Practices", Vlad...
"PHP Code Avengers: Structuring, Refactoring, and Superhero Practices", Vlad...
Fwdays
Code Smells Part 1: Basic Smells
Code Smells Part 1: Basic Smells
Nancy Henson
Code Smells and Its type (With Example)
Code Smells and Its type (With Example)
Anshul Vinayak
Code smell overview
Code smell overview
Pham Manh Lan
Clean code - DSC DYPCOE
Clean code - DSC DYPCOE
Patil Shreyas
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standards
Perfomatix Solutions
Selenium Design Patterns
Selenium Design Patterns
Liraz Shay
TDD Are you sure you properly test code?
TDD Are you sure you properly test code?
Dmitriy Nesteryuk
Mca2030 object oriented programming c++
Mca2030 object oriented programming c++
smumbahelp
Mca2030 object oriented programming c++
Mca2030 object oriented programming c++
smumbahelp
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Kaunas Java User Group
Code Smells - Refactoring
Code Smells - Refactoring
Shobi P P
Clean code: understanding Boundaries and Unit Tests
Clean code: understanding Boundaries and Unit Tests
radin reth
Code Smell and Refactoring
Code Smell and Refactoring
kimsrung lov
Ad

Recently uploaded (20)

Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
Overview of Employee in Odoo 18 - Odoo 際際滷s
Overview of Employee in Odoo 18 - Odoo 際際滷s
Celine George
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
How to Create an Event in Odoo 18 - Odoo 18 際際滷s
How to Create an Event in Odoo 18 - Odoo 18 際際滷s
Celine George
What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
Introduction to problem solving Techniques
Introduction to problem solving Techniques
merlinjohnsy
Paper 108 | Thoreaus Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreaus Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
Overview of Employee in Odoo 18 - Odoo 際際滷s
Overview of Employee in Odoo 18 - Odoo 際際滷s
Celine George
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
How to Create an Event in Odoo 18 - Odoo 18 際際滷s
How to Create an Event in Odoo 18 - Odoo 18 際際滷s
Celine George
What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
Introduction to problem solving Techniques
Introduction to problem solving Techniques
merlinjohnsy
Paper 108 | Thoreaus Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreaus Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
Ad

Code smells quality of code

  • 3. Introduction Code smells are not bugs or errors. Instead, these are absolute violations of the fundamentals of developing software that decrease the quality of code. Having code smells does not certainly mean that the software wont work, it would still give an output, but it may slow down processing, increased risk of failure and errors while making the program vulnerable to bugs in the future. Smelly code contributes to poor code quality and hence increasing the technical debt. Any fool can write code that a computer can understand, good programmers write code that every human can understand. - Martin Fowler
  • 4. Code Smell Example Comments Are Comments necessary? 1. Why? 2. What? 3. Comments are for people not for machines. 4. Think about refactoring the code so that comments are not needed. Long Method Try avoiding longer methods. Short methods are easier to read & understand for a developer who looks at the code. 1. Ideal lines of code -20. 2. Methods with 5 lines of code, indicate that you are breaking up the code too much, making it harder to understand,
  • 5. Code Smell Example (Cont.) Too Many Parameters Avoid to many parameters in the method signature. 1. Ideal number of parameters (as per checkstyle static code analyzer) -7 2. Keeping it less than 5 makes it easy to read understand. Type Embedded in Name Avoid embedding types to the variable names. Some Bad Example 1. List<String> listofStudents; 2. String sStudent; 3. Int iAmmount
  • 6. Code Smell Example (Cont.) Inconsistent Names Many developers have trouble with naming the methods with the efficient name. Examples 1. Use lower case for packages. 2. Use camel case of variables and method names. 3. Avoid using _ Dead Code Unused code? Or commented code? Delete is before push to repository.
  • 7. Code Smell Example (Cont.) Solution Sprawl If you have too many classes to perform a solution, you might have solution sprawl. Time to refactor the code.
  • 8. Application Level Smells 1. Duplicate Code - Similar code in more than one location. 2. Shotgun Surgery - One change requires altering many different classes. 3. Contrived Complexity - Using complex design patterns where a simpler uncomplicated design could be used.
  • 9. Class Level Smells 1. Large Class - Class trying to do too much and has too many instance variables. 2. Freeloader - Class doing too little 3. Feature Envy - Class with a method that seems more interested in other class than the one it is in. 4. Divergent Code - A class that suffers many kinds of changes to bring a change in a system. 5. Data Clump - Bunches of data that clump together in lots of places. 6. Inappropriate Intimacy - A class that has dependencies on implementation details of other class. 7. Middle Man - Class with lots of methods delegated to other class. 8. Downcasting - Typecast that breaks the abstraction model. 9. Parallel Inheritance Hierarchy - Every time you make a subclass for a single class, you are needed to make subclass. 10. Refused Bequest - Subclass not using methods and data of superclass. 11. Cyclomatic Complexity - Class with too many branches and loops.
  • 10. Method Level Smells 1. Long Method - Long procedures that are hard to understand. 2. Speculative Generality - Methods whose only users are test cases. 3. Message Chains - Method calling a different method which calls a different method which calls a different method and on and on. 4. Too Many Parameters - A very long list of parameters. 5. Oddball Solutions - When multiple methods are used to solve the same problem in one program creating inconsistency. 6. God Line - An excessively long line of code. 7. Excessive Returner - A method that returns more data than what its caller needs. 8. Identifier Size - The identifier is excessively short or long.