SlideShare a Scribd company logo
1 of 5
software
craftsmanship
rsingla@ford.com
Code Smells
Introduction
Code
Review
Code
Review
WTF!
Hmm..
WTF is this
sh**!
WTF! We are in
deep trouble!
WTF!
Dude,
WTF!
When is this going
to end!
Good Code Bad Code
GOOD CODE
MaintainableExtensibleReadable
MOST IMPORTANT!
Cost of Software
Readability. Why?
Understand
Analyze
Create/Change
Test
Build
Deploy
Object-Orientation Abusers
4
5
Change Preventers
Couplers
3
2
Bloaters
1
Dispensables
CODE SMELLS!!!

More Related Content

What's hot

Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)
Peter Kofler
 
Coding Dojo: Adding Tests to Legacy Code (2014)
Coding Dojo: Adding Tests to Legacy Code (2014)Coding Dojo: Adding Tests to Legacy Code (2014)
Coding Dojo: Adding Tests to Legacy Code (2014)
Peter Kofler
 
Java User Groups in Austria (2013)
Java User Groups in Austria (2013)Java User Groups in Austria (2013)
Java User Groups in Austria (2013)
Peter Kofler
 
Coding Dojo: Mars Rover (2014)
Coding Dojo: Mars Rover (2014)Coding Dojo: Mars Rover (2014)
Coding Dojo: Mars Rover (2014)
Peter Kofler
 

What's hot (19)

Brutal Coding Constraints (ITAKE 2017)
Brutal Coding Constraints (ITAKE 2017)Brutal Coding Constraints (ITAKE 2017)
Brutal Coding Constraints (ITAKE 2017)
 
Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)
 
Pair Programming (2015)
Pair Programming (2015)Pair Programming (2015)
Pair Programming (2015)
 
Make a better with clean code
Make a better with clean codeMake a better with clean code
Make a better with clean code
 
Coding Dojo - Refactoring Tennis Kata
Coding Dojo - Refactoring Tennis KataCoding Dojo - Refactoring Tennis Kata
Coding Dojo - Refactoring Tennis Kata
 
Coding Dojo: Adding Tests to Legacy Code (2014)
Coding Dojo: Adding Tests to Legacy Code (2014)Coding Dojo: Adding Tests to Legacy Code (2014)
Coding Dojo: Adding Tests to Legacy Code (2014)
 
TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)
 
Lesson 4 - Planning
Lesson 4 - PlanningLesson 4 - Planning
Lesson 4 - Planning
 
高品質軟體的基本動作 101 + 102 for NUU
高品質軟體的基本動作 101 + 102 for NUU高品質軟體的基本動作 101 + 102 for NUU
高品質軟體的基本動作 101 + 102 for NUU
 
BDD in Action: Building Software Right and Building the Right Software
BDD in Action: Building Software Right and Building the Right SoftwareBDD in Action: Building Software Right and Building the Right Software
BDD in Action: Building Software Right and Building the Right Software
 
TDD as if You Meant It (2013)
TDD as if You Meant It (2013)TDD as if You Meant It (2013)
TDD as if You Meant It (2013)
 
GDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran CanariaGDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran Canaria
 
Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)
 
BDD in Action - building software that matters
BDD in Action - building software that mattersBDD in Action - building software that matters
BDD in Action - building software that matters
 
Get into game programming
Get into game programmingGet into game programming
Get into game programming
 
Java User Groups in Austria (2013)
Java User Groups in Austria (2013)Java User Groups in Austria (2013)
Java User Groups in Austria (2013)
 
Code Retreat Venice (2016)
Code Retreat Venice (2016)Code Retreat Venice (2016)
Code Retreat Venice (2016)
 
Designing Test Cases for the Gilded Rose Kata v3 (2016)
Designing Test Cases for the Gilded Rose Kata v3 (2016)Designing Test Cases for the Gilded Rose Kata v3 (2016)
Designing Test Cases for the Gilded Rose Kata v3 (2016)
 
Coding Dojo: Mars Rover (2014)
Coding Dojo: Mars Rover (2014)Coding Dojo: Mars Rover (2014)
Coding Dojo: Mars Rover (2014)
 

More from Rajat Singla

More from Rajat Singla (8)

Compliance Psychology
Compliance PsychologyCompliance Psychology
Compliance Psychology
 
Introduction to Bill Of Materials
Introduction to Bill Of MaterialsIntroduction to Bill Of Materials
Introduction to Bill Of Materials
 
Software Craftsmanship - Code Smells - Change Preventers
Software Craftsmanship - Code Smells - Change PreventersSoftware Craftsmanship - Code Smells - Change Preventers
Software Craftsmanship - Code Smells - Change Preventers
 
Software Craftsmanship - Code Smells - Object Orientation Abusers
Software Craftsmanship - Code Smells - Object Orientation AbusersSoftware Craftsmanship - Code Smells - Object Orientation Abusers
Software Craftsmanship - Code Smells - Object Orientation Abusers
 
Software Craftsmanship - Code Smells - Couplers
Software Craftsmanship - Code Smells - CouplersSoftware Craftsmanship - Code Smells - Couplers
Software Craftsmanship - Code Smells - Couplers
 
Software Craftsmanship - Code Smells - Dispensables
Software Craftsmanship - Code Smells - DispensablesSoftware Craftsmanship - Code Smells - Dispensables
Software Craftsmanship - Code Smells - Dispensables
 
Software Craftsmanship - Code Smells - Bloaters
Software Craftsmanship - Code Smells - BloatersSoftware Craftsmanship - Code Smells - Bloaters
Software Craftsmanship - Code Smells - Bloaters
 
Introduction to Software Craftsmanship
Introduction to Software CraftsmanshipIntroduction to Software Craftsmanship
Introduction to Software Craftsmanship
 

Recently uploaded

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

Software Craftsmanship - Introduction to Code Smells

Editor's Notes

  1. This is my second presentation on software craftsmanship. My previous presentation was a high level view highlighting the dire need of software craftsmanship on top of agile in software development. This presentation (and the subsequent series on code smells) deep dives into the technical aspect of software craftsmanship highlighting ways to structure your code and write a well crafted software.
  2. What according to you is a good code? Or what according to you is a bad code? How do we measure code quality? There is a very simple method to determine whether a code is good or bad. Imagine yourself having a code review with your team. The count of WTFs shouted per minute in the room is all you need to determine whether your code is good or not!
  3. The ideal requirements for a code to be labeled Good are: It should be Readable. People should not have a confused expression on their faces while reading your code. The code should clearly depict the intentions of the programmer. Every line that goes inside your code should be a depiction of the business scenario it is representing. Just by looking at the code, a person should be able to deduce what the code is doing and how it is done. It should be Extensible. Requirements keep on changing. Every day new features come up. The code should have an ability to accommodate the ever increasing demand of features without exploding. If you find it really hard to accommodate a small feature in your code, it is a sign of imminent explosion and your code should be restructured immediately. It should be Maintainable. A code which does not stand the test of time, is a code with zero value. Your code should not only aim to solve the immediate problem at hand, but should be robust enough to handle problems in the future. Most often than not, person maintaining the code is different from the person who has developed it. If it takes hours to understand your code it is not maintainable. If for a small change in requirement, you are forced to change huge amount of code, your code is at a risk of breaking down and it is definitely not maintainable (your code might have high coupling). Would you buy a car which demands high cost of maintenance and requires you to visit dealership often?
  4. Often when I tell people that readability is the most important aspect of your code, people quickly disregard it thinking I am a guy obsessed with beautifying my code and keeping things organized. What they fail to understand is that beautiful code is not really a reason, but a result of taking care of perhaps the most important factor determining the cost of your software! What factors determine the cost of your software? Lets start by writing down the steps involved in creating one! Analyze -> Change/Create -> Test -> Build -> Deploy. It is fairly understandable that time spent on each stage is in the decreasing order. We all know, the cost involved is a direct function of time, specially when it comes to software development (Time = Money, Duh!). So the cost goes in the decreasing order as well. FAIR ENOUGH! Are we not missing something? What most people fail to consider in their time analysis of creating a software is the time it takes to Understand the Problem! Ask yourself, how much time you spend understanding a piece of code before working on it. Where do you think, the stage of understanding fits in this chain? RIGHT AT THE TOP! Isn’t it? Doesn’t it mean that the cost of understanding is higher than all other costs? Wouldn’t reducing time involved in this stage reduce the cost of your software immensely? And what is the single most important factor determining the time involved in understanding the code? It is CODE READABILITY!! Making your code readable should thus be of prime importance while writing you code. A beautiful code is just a side effect of this task. And lets not call it beautiful. Technically, it should be called a “well structured code”. And the tool that is available to every developer for doing this, is FREE OF COST! It is called REFACTORING! Common argument: What about performance? Answer: MAKE YOUR CODE READABLE FIRST! THEN LOOK FOR PERFORMANCE! -> MAKE IT WORK, THEN MAKE IT BETTER! (how to make it readable - e.g. Guard Clause, Intention Revealing Names etc.)
  5. Now how do we know that code we have written is good or bad? Is it a subjective opinion or is there any metrics to determine whether it is readable/extensible/maintainable? Luckily for us, there IS A METRIC! When you go past a garbage can, you tend to block your nose, as the foul smell is almost unbearable. When there is something wrong with the code, we say there are certain elements in it which stink, making the whole code stink as well! These stinky elements are referred to as code smells. Now, when it comes to real life objects, the sense of foul smell is an innate human tendency. But when it comes to code, we need to teach ourselves to identify these code smells. In other words, we need to develop a nose to identify foul smells in the code. And this ability can only be developed when you are relatively young (new to development). As soon as a hatchling starts flying, its mother teaches it to hunt, for it won’t survive in its adulthood without the ability. The same goes with the ability to smell stink inside the code. It becomes harder and harder to develop this ability as we grow further into software development without it. For it is easier to learn than to unlearn. Writing a code with wrong practices is more dangerous than not writing the code at all! IT IS VERY IMPORTANT FOR ANY YOUNG DEVELOPER TO DEVELOP A NOSE FOR THESE CODE SMELLS! There are broadly 5 categories these code smells are divided into. The subsequent slides will talk about each of them in detail, highlighting different ways these code smells make your code stink and how to identify these smells and remove them.