SlideShare a Scribd company logo
Refuctoring
(The process of taking a well-designed piece of code and, through a series of
small, reversible changes, making it completely unmaintainable by anyone
except yourself.)
Code Smells
Well it doesn't have a nose... but it
definitely can stink!
Ingredients
● Comments
● Long Method, Large Class
● Long parameter list
● Duplicated code
● Dead Code
● Temporary variables
● Conditional Complexity
● Combinatorial Explosion
● Uncommunicative/Inconsistent
Names
Comments
● The best comment is a good name for a
method or class.
● The code is is supposed to explain itself. In
that case comments are not needed
Comments can be useful
● When explaining why something is being
implemented in a particular way.
● When explaining complex algorithms (when all
other methods for simplifying the algorithm
have been tried and come up short).
Long Methods &
Long Classes (God Class)
Classes usually start small. But over
time, they get bloated as the program
grows.
As is the case with long methods as
well,
Long Parameters
Duplicated
Code
Duplicated code is the bane of
software development. Stamp
out duplication whenever
possible. You should always be
on the lookout for more subtle
cases of near-duplication, too.
Don't Repeat Yourself!
Dead Code
● When requirements for the software
have changed or corrections have been
made, nobody had time to clean up the
old code.
● Such code could also be found in
complex conditionals, when one of
the branches becomes unreachable
(due to error or other circumstances).
Temporary
Variables
● Temporary variables are
quick and easy way to store
and manipulate data around.
● But over time they stick
around you with bad smell.
Conditional Complexity
● Watch out for large conditional logic
blocks, particularly blocks that tend to
grow larger or change significantly over
time. Consider alternative object-
oriented approaches such as decorator,
strategy.
Combinatorial
Explosion
● You have lots of code that
does almost the same thing..
but with tiny variations in
data or behavior.
Uncommunicative/Inconsistent Names
● Does the name of the method succinctly
describe what that method does? Could
you read the method's name to another
developer and have them explain to you
what it does? If not, rename it or rewrite
it.
● $category or $cat ?
● $cat or $c ?
● $subcategory or $SubCategory or
$sub_category or $s_cat or $s_c
There are two ways to write
error-free programs;
Only the third one works.(Alan Jay Perlis)
Shobi P P
shobi@storat.com
Reference
https://blog.codinghorror.com/code-smells/

More Related Content

PPT
Code sense
PDF
PDF
Object Calisthenics in Objective-C
PPT
Notesparadigms
PDF
Evolutionary Design - Refactoring Heuristics
PPT
Chapter 09
PDF
Comparison of Type Systems
PDF
Tdd in practice
Code sense
Object Calisthenics in Objective-C
Notesparadigms
Evolutionary Design - Refactoring Heuristics
Chapter 09
Comparison of Type Systems
Tdd in practice

What's hot (20)

PPT
JavaScript Variables
PDF
Revisit: Best Practices in Scala
PPTX
Competitive Programming Guide
PDF
Better programmer overview
PPTX
Software Design Principles and Best Practices - Satyajit Dey
PPTX
Introduction to Competitive programming
PDF
Black Box Machine Learning Models: Issues and Opportunities | Thomas Y. Chen,...
PDF
Fundamentals of programming)
PPTX
Clean code
PPTX
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
PPTX
What not to study for the apcs exam, and other exam tips
PPTX
Code smells quality of code
PDF
Emarsys XP reggeli 2016.08.12.
PDF
I'm a TDD cheat and I'm not afraid to admit it
PPTX
15 interfaces
PPTX
DRY or die
PPTX
13. interfaces
PPTX
When to use abstract class and methods in java
PPTX
Lab view (Getting Started)
JavaScript Variables
Revisit: Best Practices in Scala
Competitive Programming Guide
Better programmer overview
Software Design Principles and Best Practices - Satyajit Dey
Introduction to Competitive programming
Black Box Machine Learning Models: Issues and Opportunities | Thomas Y. Chen,...
Fundamentals of programming)
Clean code
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
What not to study for the apcs exam, and other exam tips
Code smells quality of code
Emarsys XP reggeli 2016.08.12.
I'm a TDD cheat and I'm not afraid to admit it
15 interfaces
DRY or die
13. interfaces
When to use abstract class and methods in java
Lab view (Getting Started)
Ad

Similar to Code Smells - Refactoring (20)

PDF
Clean Code
ODP
Clean Code - Part 2
PDF
PDF
Code Smell and Refactoring
PDF
Software Craftmanship - Cours Polytech
PPTX
Bad Smells in Code
ODP
How to code
PDF
Single Responsibility Principle
PPTX
Clean code - DSC DYPCOE
PPTX
Code quality
PPTX
A Pragmatic Approach
PDF
YAGNI Principle and Clean Code
PPTX
Code Metrics
PPTX
Cinci ug-january2011-anti-patterns
PDF
Another Tale of Two Patterns
PPTX
Code smell overview
PPTX
Principled And Clean Coding
PDF
Writing Readable Code
PDF
Clean code-v2.2
PDF
Basics of writing clean code
Clean Code
Clean Code - Part 2
Code Smell and Refactoring
Software Craftmanship - Cours Polytech
Bad Smells in Code
How to code
Single Responsibility Principle
Clean code - DSC DYPCOE
Code quality
A Pragmatic Approach
YAGNI Principle and Clean Code
Code Metrics
Cinci ug-january2011-anti-patterns
Another Tale of Two Patterns
Code smell overview
Principled And Clean Coding
Writing Readable Code
Clean code-v2.2
Basics of writing clean code
Ad

Recently uploaded (20)

PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
top salesforce developer skills in 2025.pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Essential Infomation Tech presentation.pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
L1 - Introduction to python Backend.pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
ai tools demonstartion for schools and inter college
PDF
System and Network Administration Chapter 2
PDF
Nekopoi APK 2025 free lastest update
How to Choose the Right IT Partner for Your Business in Malaysia
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
VVF-Customer-Presentation2025-Ver1.9.pptx
CHAPTER 2 - PM Management and IT Context
Odoo Companies in India – Driving Business Transformation.pdf
Operating system designcfffgfgggggggvggggggggg
top salesforce developer skills in 2025.pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Essential Infomation Tech presentation.pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PTS Company Brochure 2025 (1).pdf.......
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
L1 - Introduction to python Backend.pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
How to Migrate SBCGlobal Email to Yahoo Easily
ai tools demonstartion for schools and inter college
System and Network Administration Chapter 2
Nekopoi APK 2025 free lastest update

Code Smells - Refactoring

  • 1. Refuctoring (The process of taking a well-designed piece of code and, through a series of small, reversible changes, making it completely unmaintainable by anyone except yourself.)
  • 2. Code Smells Well it doesn't have a nose... but it definitely can stink! Ingredients ● Comments ● Long Method, Large Class ● Long parameter list ● Duplicated code ● Dead Code ● Temporary variables ● Conditional Complexity ● Combinatorial Explosion ● Uncommunicative/Inconsistent Names
  • 3. Comments ● The best comment is a good name for a method or class. ● The code is is supposed to explain itself. In that case comments are not needed Comments can be useful ● When explaining why something is being implemented in a particular way. ● When explaining complex algorithms (when all other methods for simplifying the algorithm have been tried and come up short).
  • 4. Long Methods & Long Classes (God Class) Classes usually start small. But over time, they get bloated as the program grows. As is the case with long methods as well,
  • 6. Duplicated Code Duplicated code is the bane of software development. Stamp out duplication whenever possible. You should always be on the lookout for more subtle cases of near-duplication, too. Don't Repeat Yourself!
  • 7. Dead Code ● When requirements for the software have changed or corrections have been made, nobody had time to clean up the old code. ● Such code could also be found in complex conditionals, when one of the branches becomes unreachable (due to error or other circumstances).
  • 8. Temporary Variables ● Temporary variables are quick and easy way to store and manipulate data around. ● But over time they stick around you with bad smell.
  • 9. Conditional Complexity ● Watch out for large conditional logic blocks, particularly blocks that tend to grow larger or change significantly over time. Consider alternative object- oriented approaches such as decorator, strategy.
  • 10. Combinatorial Explosion ● You have lots of code that does almost the same thing.. but with tiny variations in data or behavior.
  • 11. Uncommunicative/Inconsistent Names ● Does the name of the method succinctly describe what that method does? Could you read the method's name to another developer and have them explain to you what it does? If not, rename it or rewrite it. ● $category or $cat ? ● $cat or $c ? ● $subcategory or $SubCategory or $sub_category or $s_cat or $s_c
  • 12. There are two ways to write error-free programs; Only the third one works.(Alan Jay Perlis) Shobi P P shobi@storat.com Reference https://blog.codinghorror.com/code-smells/

Editor's Notes

  • #6: getListingBanners()