SlideShare una empresa de 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>

Más contenido relacionado

Similar 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
 

Similar 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
 

Más 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
 

Último (20)

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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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, ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 

Dude, I just stepped into your code

Notas del 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