SlideShare uma empresa Scribd logo
1 de 20
Dude, I Just Stepped
I n t o Yo u r C o d e !
Josh Gillespie
Polaris Solutions
St. Louis Days of .NET
Platinum
Sponsors

Gold Sponsors

Silver
Sponsors
What is a code smell?
Wikipedia says…
• In computer programming, code smell is any symptom in
the source code of a program that possibly indicates a deeper
problem. Code smells are usually not bugs—they are not
technically incorrect and don't currently prevent the program
from functioning. Instead, they indicate weaknesses in design
that may be slowing down development or increasing the risk of
bugs or failures in the future.
Can you smell that?
Tr a i n y o u r n o s e !
Approach
• Identify the source
• Decide if it indicates a problem
• Decide if the fix is worthwhile
• Refactor
• Retest
Duplicated
Code
Shotgun Surgery
Indecent Exposure
(Feature)
Switch Statements
Long Parameter list
Names
Comments
Questions?
Thank you!
Josh Gillespie
Josh.Gillespie@polarissolutions.com
Metadata
Image Credits
•

http://www.flickr.com/photos/uxud/3666539245/

•

http://www.flickr.com/photos/janramroth/2100683729/

•

http://www.flickr.com/photos/hexadecimal_time/2707620512

•

http://www.flickr.com/photos/icanchangethisright/3810853622/

•

http://www.flickr.com/photos/92305862@N00/2307386482/

•

http://www.flickr.com/photos/mkumm/3043730066/

•

http://www.flickr.com/photos/adactio/2856955322/

•

http://fallout.wikia.com/wiki/Shotgun_Surgeon

•

http://www.flickr.com/photos/10804763@N07/1128953541/

•

http://www.flickr.com/photos/hey__paul/5841439462/

•

http://www.flickr.com/photos/chicanerii/8682931402/

•

http://www.flickr.com/photos/dr1066/203919554/

•

http://www.flickr.com/photos/bingmanson/6347195986/

•

http://www.flickr.com/photos/quinnanya/4869433260/

•

http://www.flickr.com/photos/soldiersmediacenter/4621703638/

•

http://www.flickr.com/photos/jm3/4683685/
Bibliography
• Mäntylä, M. V. and Lassenius, C. "Subjective Evaluation of Software
Evolvability Using Code Smells: An Empirical Study". Journal of
Empirical Software Engineering, vol. 11, no. 3, 2006, pp. 395-431.
• Brown, William J., Raphael C. Malveau, Hays W. McCormick, and Thomas
J. Mowbray. Antipatterns: Refactoring Software, Architectures, and
Projects in Crisis. NY: Wiley, 1998.
• Fowler, Martin, Kent Beck, John Brant, William Opdyke, and Don
Roberts. Refactoring: Improving the Design of Existing Code.
Reading, MA: Addison-Wesley Professional, 1999.
• Bock, David, “The Paperboy, The Wallet, and The Law Of Demeter”.
Web. 1 Nov 2013, <http://www.ccs.neu.edu/research/demeter/demetermethod/LawOfDemeter/paper-boy/demeter.pdf>
• Atwood, Jeff. “Code Smells”, 18 May 2006. Web. 1 Oct 2013.
<http://www.codinghorror.com/blog/2006/05/code-smells.html>

Mais conteúdo relacionado

Semelhante a Dude, I just stepped into your code

Generic Attack Detection - ph-Neutral 0x7d8
Generic Attack Detection - ph-Neutral 0x7d8Generic Attack Detection - ph-Neutral 0x7d8
Generic Attack Detection - ph-Neutral 0x7d8
Mario Heiderich
 
How To Do Kick-Ass Software Development, by Sven Peters
How To Do Kick-Ass Software Development, by Sven PetersHow To Do Kick-Ass Software Development, by Sven Peters
How To Do Kick-Ass Software Development, by Sven Peters
ZeroTurnaround
 

Semelhante a Dude, I just stepped into your code (20)

Dev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and FlickrDev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and Flickr
 
Enhancing Developer Productivity with Code Forensics
Enhancing Developer Productivity with Code ForensicsEnhancing Developer Productivity with Code Forensics
Enhancing Developer Productivity with Code Forensics
 
BSides LA/PDX
BSides LA/PDXBSides LA/PDX
BSides LA/PDX
 
Devoxx Poland 2015: 5-10-15 years with Java
Devoxx Poland 2015: 5-10-15 years with Java Devoxx Poland 2015: 5-10-15 years with Java
Devoxx Poland 2015: 5-10-15 years with Java
 
5-10-15 years of Java developer career - Warszawa JUG 2015
5-10-15 years of Java developer career - Warszawa JUG 20155-10-15 years of Java developer career - Warszawa JUG 2015
5-10-15 years of Java developer career - Warszawa JUG 2015
 
Generic Attack Detection - ph-Neutral 0x7d8
Generic Attack Detection - ph-Neutral 0x7d8Generic Attack Detection - ph-Neutral 0x7d8
Generic Attack Detection - ph-Neutral 0x7d8
 
My life as a cyborg
My life as a cyborg My life as a cyborg
My life as a cyborg
 
Software developer interview fails
Software developer interview failsSoftware developer interview fails
Software developer interview fails
 
From TrainedMonkey to Google SoC mentor – How to become an OOo developer
From TrainedMonkey to Google SoC mentor – How to become an OOo developerFrom TrainedMonkey to Google SoC mentor – How to become an OOo developer
From TrainedMonkey to Google SoC mentor – How to become an OOo developer
 
Stamp Out Agile and DevOps Bottlenecks
Stamp Out Agile and DevOps BottlenecksStamp Out Agile and DevOps Bottlenecks
Stamp Out Agile and DevOps Bottlenecks
 
Why you should integrate peer code reviews in your software company
Why you should integrate peer code reviews in your software companyWhy you should integrate peer code reviews in your software company
Why you should integrate peer code reviews in your software company
 
TDD - Cultivating a Beginner's Mind
TDD -  Cultivating a Beginner's MindTDD -  Cultivating a Beginner's Mind
TDD - Cultivating a Beginner's Mind
 
Bug Bounty - Play For Money
Bug Bounty - Play For MoneyBug Bounty - Play For Money
Bug Bounty - Play For Money
 
How not to run code reviews
How not to run code reviewsHow not to run code reviews
How not to run code reviews
 
Beyond the Hack
Beyond the HackBeyond the Hack
Beyond the Hack
 
How To Do Kick-Ass Software Development, by Sven Peters
How To Do Kick-Ass Software Development, by Sven PetersHow To Do Kick-Ass Software Development, by Sven Peters
How To Do Kick-Ass Software Development, by Sven Peters
 
Empirical Methods in Software Engineering - an Overview
Empirical Methods in Software Engineering - an OverviewEmpirical Methods in Software Engineering - an Overview
Empirical Methods in Software Engineering - an Overview
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016
 
Waste Driven Development - Agile Coaching Serbia Meetup
Waste Driven Development - Agile Coaching Serbia MeetupWaste Driven Development - Agile Coaching Serbia Meetup
Waste Driven Development - Agile Coaching Serbia Meetup
 
Harkable Day of Innovation Oct 2013 - Hark in the Park
Harkable Day of Innovation Oct 2013 - Hark in the ParkHarkable Day of Innovation Oct 2013 - Hark in the Park
Harkable Day of Innovation Oct 2013 - Hark in the Park
 

Mais de Josh Gillespie (7)

Introduction to Containers: What, Why, and How
Introduction to Containers: What, Why, and HowIntroduction to Containers: What, Why, and How
Introduction to Containers: What, Why, and How
 
Practical Security Practices: Threat Modeling
Practical Security Practices: Threat ModelingPractical Security Practices: Threat Modeling
Practical Security Practices: Threat Modeling
 
Exposing the Spy in Your Pocket
Exposing the Spy in Your PocketExposing the Spy in Your Pocket
Exposing the Spy in Your Pocket
 
Automation: PowerShell & DSC
Automation: PowerShell & DSCAutomation: PowerShell & DSC
Automation: PowerShell & DSC
 
Teaching the cloud to think
Teaching the cloud to thinkTeaching the cloud to think
Teaching the cloud to think
 
Who are you?
Who are you?Who are you?
Who are you?
 
A DevOps Discussion
A DevOps DiscussionA DevOps Discussion
A DevOps Discussion
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

Dude, I just stepped into your code

Notas do Editor

  1. IntroductionsGround rulesAssess the audience
  2. A code smell isn’t necessarily bad. Meaning, a smell doesn’t mean something IS wrong, just that is MIGHT be wrong and warrants further investigation.
  3. In computer programming, code smell is any symptom in the source code of a program that possibly indicates a deeper problem. Code smells are usually not bugs—they are not technically incorrect and don&apos;t currently prevent the program from functioning. Instead, they indicate weaknesses in design that may be slowing down development or increasing the risk of bugs or failures in the future.
  4. The definition we have so far is pretty vague.Part of why I love the term “code smell” is it imparts that sense of subtlety.What smells to me may not smell to you.Developing your “code nose” is a career long endeavor.
  5. So how do you train your nose? Practice!We’ll start by talking about some of the more obvious, smellier smells and work our way “down” to the more subtle.And we’re going to take the same approach to each one.
  6. Ground RulesWhat’s the problem?Why is it a problem?What is the fix?Is the fix worth it?
  7. The worst code smell of all.Why is this bad? Complicates maintenance. May be indicative of green programmers, arch misunderstanding, etcSimilar to Dead Code, Lazy Code, etc.Very rarely is this legit. When could it be legit?
  8. I would not recommend doing an image search for this phrase….What’s the problem?Why is it a problem?What is the fix?Is the fix worth it?
  9. Beware of classes that unnecessarily expose their internals. Refactor classes to minimize their surface area. If you don&apos;t have a good reason to make it public, hide it.What’s the problem?Why is it a problem?What is the fix?Is the fix worth it?
  10. What’s the problem?Why is it a problem?What is the fix?Is the fix worth it?
  11. Why is it a problem? Switch Statement might be considered acceptable or even good design in procedural programming, but is something that should be avoided in object-oriented programming. What is the fix?Is the fix worth it?The situation where switch statements or type codes are needed should be handled by creating subclasses
  12. Paging parameters / Format Parameters (XML, json, etc)What’s the problem?Why is it a problem?What is the fix?Is the fix worth it?
  13. What’s the problem?Why is it a problem?What is the fix?Is the fix worth it?
  14. Comments are a smellXML Method comments, inline comments, Commented Code is just plain terribleViolates DRY, and if it doesn’t, you’ve violated something else…Inline comments often means the workings aren’t clear. Make the intent more obvious. When is it okay? Why is it bad? Interface comments – sometimes helpful (e.g. arguments that the method might throw, example usage, etc).Implementation comments – smellComments don’t compile, meaning they can be flat wrong and things still run