SlideShare a Scribd company logo
Code Smells
and other
Malodorous
Software Odors
Clint Edmonson
clint@polarissolutions.com
We need to talk…
Code Smell
Code smell, also known as bad smell in computer programming
code, refers to any symptom in the source code of a program that
may contain an area of concern.
According to Martin Fowler, "a code smell is a surface indication
that usually corresponds to a deeper problem in the system".
https://en.wikipedia.org/wiki/Code_smell
Code Sleuth
• A smell is by definition something that's quick to spot - or sniffable
• Smells don't always indicate a problem
• The best smells are easy to spot and most of time lead you to really
interesting problems
• It's easy for inexperienced people to spot them, even if they don't
know enough to evaluate if there's a real problem or to correct them
Martin Fowler
https://www.martinfowler.com/bliki/CodeSmell.html
Prepare your
sniffers…
Low Value Comments
Comments that don’t enhance understanding of the code.
Comments add value when:
• They describe the purpose of the code (why), not the what or
how
• Explain the steps in an algorithm
Dead Code
Large blocks of code commented out and/or methods and classes that
are left in the code but no longer used in favor of newer functionality.
Dead code makes it harder to understand and maintain the system.
Quick fix:
• DELETE IT!
• If we ever want to see it again, we can look it up in source control
history.
Marathon Methods
If it’s more than a screenful, its too much!
Some guidance:
• A method should have AT MOST 10-12 steps
• Extract large blocks into their own methods
• You will OFTEN find duplicated code
• A good looking method should look like the steps in a recipe
book
Magic Numbers & Strings
Hard coded numbers and string values inside methods.
Generally based on an assumption or implicit knowledge and frequently duplicated
in multiple places.
Very susceptible to fat-fingering errors.
Remedies:
• Refactor to enums and use implicit conversions to ints or strings when
absolutely needed
• Consolidate down to static and read-only class fields and properties
• Strive to make the application data driven through a config or settings component
Duplicate/Triplicate Code
Code fragments that look almost identical.
Could occur when multiple work on a code base and are unware of existing code
that could be used or refactored to be re-used.
Also occurs in haste when trying to meet a deadline and unable to resist the
temptation to copy and tweak a working class or method.
Advice:
• Refactoring is NOT something you do later! You are making things worse.
• ALWAYS use the Red-Green-Refactor cycle when coding
• You are a professional developer - make sure the code you are checking in is the
BEST work you can do and you would be proud to show someone else.
The Blob Class
Lots of methods and properties, making the code difficult to read,
understand, and troubleshoot.
Often indicates that the class contains too many responsibilities.
Remedies:
• Can the large class be restructured or broken into smaller
classes?
• Use the Class Responsibility Collaborator (CRC) card exercise
to discover a better OO model
Speculative Code
Tutorial, experimental or research code checked into the production
code base.
Code semantics are frequently different from the problem being
solved.
Advice:
• If you are exploring a solution or learning a new technique, do it in a
blank project or private branch until you are satisfied that it solves
your design problem
• Re-implement it in the production code base using intent-driven
development
Not Invented Here (NIH) Syndrome
Code that re-invents the wheel. Pursuit of an interesting problem
trumps the needs of the project.
The right thing to do:
• Leverage well known, documented frameworks
• Avoid creating your own Rube Goldberg machine
Stack Overflow
Programming
Trusting someone else’s code
to solve your problem without
truly understanding how
and/or why it works.
Solution:
• Practice intent-driven
development
• Code with intent and purpose
• Understand EVERY line of
code you write
And many, many more…
Wikipedia
• https://en.wikipedia.org/wiki/Code_smell
Sourcemaking online lessons
• https://sourcemaking.com/refactoring/smells
Smells to Refactorings
• http://www.industriallogic.com/wp-
content/uploads/2005/09/smellstorefactorings.pdf
Homework Assignment
• Solution Sprawl
• Leaky Abstraction
• Inappropriate Intimacy
• Indecent Exposure
• 7 Layer Cake
• Uncommunicative Name
• Inconsistent Naming
Where do these smells
come from?
Primal Forces
• Haste – sacrificing integrity for expedience
• Sloth – making poor decisions based on the “easy” answer
• Apathy – not caring about solving known problems
• Narrow-mindedness – refusal to practice widely-known solutions
• Avarice – putting own intellectual pursuits above the needs of the
problem at hand
• Ignorance – failing to seek understanding before solving a problem
• Pride – inventing new designs when existing solutions could readily
be applied (NIH syndrome)
What do we do about them?
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and
// will be lost if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
Don’t be a tool!
Practice
Intent Driven Development!
Thank You!
Clint Edmonson
clint@polarissolutions.com
Drop by the booth or visit us online at
https://polarissolutions.com

More Related Content

What's hot

Basics of Computer Coding: Understanding Coding Languages
Basics of Computer Coding: Understanding Coding LanguagesBasics of Computer Coding: Understanding Coding Languages
Basics of Computer Coding: Understanding Coding Languages
Brian Pichman
 
Hack It 'Til You Make It: Acing The Technical Interview
Hack It 'Til You Make It: Acing The Technical InterviewHack It 'Til You Make It: Acing The Technical Interview
Hack It 'Til You Make It: Acing The Technical Interview
jaysonjphillips
 
NUS Hackers Project Intern 2016
NUS Hackers Project Intern 2016NUS Hackers Project Intern 2016
NUS Hackers Project Intern 2016
Vishnu Prem
 
Hiring Backend Engineers
Hiring Backend EngineersHiring Backend Engineers
Hiring Backend Engineers
Vaidas Pilkauskas
 
Coderetreat - Practice to Master Your Crafts
Coderetreat - Practice to Master Your CraftsCoderetreat - Practice to Master Your Crafts
Coderetreat - Practice to Master Your Crafts
Lemi Orhan Ergin
 
The Smells Of Bad Design
The Smells Of Bad DesignThe Smells Of Bad Design
The Smells Of Bad Designguest446c0
 
Bug Hunting Safari
Bug Hunting SafariBug Hunting Safari
Bug Hunting Safari
Janie Clayton
 
Memos case study Innerworkings
Memos case study InnerworkingsMemos case study Innerworkings
Memos case study Innerworkings
Apro Software
 
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
Matts Devriendt
 
Technology Stack
Technology StackTechnology Stack
Technology Stack
SV.CO
 
Build your own Language - Why and How?
Build your own Language - Why and How?Build your own Language - Why and How?
Build your own Language - Why and How?
Markus Voelter
 
Coding Introductory Lesson Upper Elementary
Coding Introductory Lesson Upper ElementaryCoding Introductory Lesson Upper Elementary
Coding Introductory Lesson Upper Elementary
Brittany Pike
 
Worst practices for domain-specific modelling
Worst practices for domain-specific modellingWorst practices for domain-specific modelling
Worst practices for domain-specific modelling
Mikhail Barash
 
DSL development
DSL developmentDSL development
DSL development
Mikhail Barash
 
Technical Writing Training for Engineers
Technical Writing Training for EngineersTechnical Writing Training for Engineers
Technical Writing Training for Engineers
parson AG
 

What's hot (20)

Lecture 31
Lecture 31Lecture 31
Lecture 31
 
Lecture 24
Lecture 24Lecture 24
Lecture 24
 
Basics of Computer Coding: Understanding Coding Languages
Basics of Computer Coding: Understanding Coding LanguagesBasics of Computer Coding: Understanding Coding Languages
Basics of Computer Coding: Understanding Coding Languages
 
Hack It 'Til You Make It: Acing The Technical Interview
Hack It 'Til You Make It: Acing The Technical InterviewHack It 'Til You Make It: Acing The Technical Interview
Hack It 'Til You Make It: Acing The Technical Interview
 
NUS Hackers Project Intern 2016
NUS Hackers Project Intern 2016NUS Hackers Project Intern 2016
NUS Hackers Project Intern 2016
 
Hiring Backend Engineers
Hiring Backend EngineersHiring Backend Engineers
Hiring Backend Engineers
 
Coderetreat - Practice to Master Your Crafts
Coderetreat - Practice to Master Your CraftsCoderetreat - Practice to Master Your Crafts
Coderetreat - Practice to Master Your Crafts
 
The Smells Of Bad Design
The Smells Of Bad DesignThe Smells Of Bad Design
The Smells Of Bad Design
 
Bug Hunting Safari
Bug Hunting SafariBug Hunting Safari
Bug Hunting Safari
 
Memos case study Innerworkings
Memos case study InnerworkingsMemos case study Innerworkings
Memos case study Innerworkings
 
Introduction
IntroductionIntroduction
Introduction
 
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
 
Technology Stack
Technology StackTechnology Stack
Technology Stack
 
Build your own Language - Why and How?
Build your own Language - Why and How?Build your own Language - Why and How?
Build your own Language - Why and How?
 
Coding Introductory Lesson Upper Elementary
Coding Introductory Lesson Upper ElementaryCoding Introductory Lesson Upper Elementary
Coding Introductory Lesson Upper Elementary
 
Worst practices for domain-specific modelling
Worst practices for domain-specific modellingWorst practices for domain-specific modelling
Worst practices for domain-specific modelling
 
DSL development
DSL developmentDSL development
DSL development
 
Fakes
FakesFakes
Fakes
 
Technical Writing Training for Engineers
Technical Writing Training for EngineersTechnical Writing Training for Engineers
Technical Writing Training for Engineers
 
Lecture 30
Lecture 30Lecture 30
Lecture 30
 

Similar to Code smells and Other Malodorous Software Odors

Developers Best Practices
Developers Best PracticesDevelopers Best Practices
Developers Best Practices
aqib javaid
 
TDD - Cultivating a Beginner's Mind
TDD -  Cultivating a Beginner's MindTDD -  Cultivating a Beginner's Mind
TDD - Cultivating a Beginner's Mind
Shai Yallin
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelines
Lalit Kale
 
Coding principles
Coding principles Coding principles
Coding principles
DevAdnani
 
Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening
Maven Logix
 
Writing clean and maintainable code
Writing clean and maintainable codeWriting clean and maintainable code
Writing clean and maintainable code
Marko Heijnen
 
Clean Code Software Engineering
Clean Code Software Engineering Clean Code Software Engineering
Clean Code Software Engineering
Inocentshuja Ahmad
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming
PostSharp Technologies
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality code
Hayden Bleasel
 
How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....
Mike Harris
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven developmentEinar Ingebrigtsen
 
Android Developer Training
Android Developer TrainingAndroid Developer Training
Android Developer Training
faizrashid1995
 
The View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tipsThe View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tipsBill Buchan
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - Implementation
Blue Elephant Consulting
 
Best pratice
Best praticeBest pratice
Best pratice
Eugenio Romano
 
Greythorn Whiteboard Interview Guide
Greythorn Whiteboard Interview GuideGreythorn Whiteboard Interview Guide
Greythorn Whiteboard Interview Guide
Vaco Seattle
 
Put to the Test
Put to the TestPut to the Test
Put to the Test
Kevlin Henney
 
How have we developed product without bugs
How have we developed product without bugsHow have we developed product without bugs
How have we developed product without bugs
Sigma Software
 
The Psychology of C# Analysis
The Psychology of C# AnalysisThe Psychology of C# Analysis
The Psychology of C# Analysis
Coverity
 

Similar to Code smells and Other Malodorous Software Odors (20)

Developers Best Practices
Developers Best PracticesDevelopers Best Practices
Developers Best Practices
 
TDD - Cultivating a Beginner's Mind
TDD -  Cultivating a Beginner's MindTDD -  Cultivating a Beginner's Mind
TDD - Cultivating a Beginner's Mind
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelines
 
Coding principles
Coding principles Coding principles
Coding principles
 
Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening
 
Writing clean and maintainable code
Writing clean and maintainable codeWriting clean and maintainable code
Writing clean and maintainable code
 
Clean Code Software Engineering
Clean Code Software Engineering Clean Code Software Engineering
Clean Code Software Engineering
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality code
 
How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
 
Android Developer Training
Android Developer TrainingAndroid Developer Training
Android Developer Training
 
The View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tipsThe View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tips
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - Implementation
 
Best pratice
Best praticeBest pratice
Best pratice
 
Greythorn Whiteboard Interview Guide
Greythorn Whiteboard Interview GuideGreythorn Whiteboard Interview Guide
Greythorn Whiteboard Interview Guide
 
Put to the Test
Put to the TestPut to the Test
Put to the Test
 
How have we developed product without bugs
How have we developed product without bugsHow have we developed product without bugs
How have we developed product without bugs
 
Quick Intro to Clean Coding
Quick Intro to Clean CodingQuick Intro to Clean Coding
Quick Intro to Clean Coding
 
The Psychology of C# Analysis
The Psychology of C# AnalysisThe Psychology of C# Analysis
The Psychology of C# Analysis
 

More from Clint Edmonson

New Product Concept Design.pptx
New Product Concept Design.pptxNew Product Concept Design.pptx
New Product Concept Design.pptx
Clint Edmonson
 
Lean & Agile Essentials
Lean & Agile EssentialsLean & Agile Essentials
Lean & Agile Essentials
Clint Edmonson
 
MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?
MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?
MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?
Clint Edmonson
 
Flow, the Universe and Everything
Flow, the Universe and EverythingFlow, the Universe and Everything
Flow, the Universe and Everything
Clint Edmonson
 
Application architecture jumpstart
Application architecture jumpstartApplication architecture jumpstart
Application architecture jumpstart
Clint Edmonson
 
State of agile 2016
State of agile 2016State of agile 2016
State of agile 2016
Clint Edmonson
 
Lean & Agile DevOps with VSTS and TFS 2015
Lean & Agile DevOps with VSTS and TFS 2015Lean & Agile DevOps with VSTS and TFS 2015
Lean & Agile DevOps with VSTS and TFS 2015
Clint Edmonson
 
Application Architecture Jumpstart
Application Architecture JumpstartApplication Architecture Jumpstart
Application Architecture Jumpstart
Clint Edmonson
 
Agile Metrics That Matter
Agile Metrics That MatterAgile Metrics That Matter
Agile Metrics That Matter
Clint Edmonson
 
Advanced oop laws, principles, idioms
Advanced oop laws, principles, idiomsAdvanced oop laws, principles, idioms
Advanced oop laws, principles, idioms
Clint Edmonson
 
Application architecture jumpstart
Application architecture jumpstartApplication architecture jumpstart
Application architecture jumpstart
Clint Edmonson
 
ADO.NET Entity Framework
ADO.NET Entity FrameworkADO.NET Entity Framework
ADO.NET Entity Framework
Clint Edmonson
 
Windows 8 - The JavaScript Story
Windows 8 - The JavaScript StoryWindows 8 - The JavaScript Story
Windows 8 - The JavaScript Story
Clint Edmonson
 
Windows Azure Jumpstart
Windows Azure JumpstartWindows Azure Jumpstart
Windows Azure Jumpstart
Clint Edmonson
 
Introduction to Windows Azure Virtual Machines
Introduction to Windows Azure Virtual MachinesIntroduction to Windows Azure Virtual Machines
Introduction to Windows Azure Virtual Machines
Clint Edmonson
 
Peering through the Clouds - Cloud Architectures You Need to Master
Peering through the Clouds - Cloud Architectures You Need to MasterPeering through the Clouds - Cloud Architectures You Need to Master
Peering through the Clouds - Cloud Architectures You Need to Master
Clint Edmonson
 
Architecting Scalable Applications in the Cloud
Architecting Scalable Applications in the CloudArchitecting Scalable Applications in the Cloud
Architecting Scalable Applications in the Cloud
Clint Edmonson
 
Windows Azure jumpstart
Windows Azure jumpstartWindows Azure jumpstart
Windows Azure jumpstart
Clint Edmonson
 
Windows Azure Virtual Machines
Windows Azure Virtual MachinesWindows Azure Virtual Machines
Windows Azure Virtual Machines
Clint Edmonson
 
A Force of One - Agile and the Solo Developer
A Force of One - Agile and the Solo DeveloperA Force of One - Agile and the Solo Developer
A Force of One - Agile and the Solo Developer
Clint Edmonson
 

More from Clint Edmonson (20)

New Product Concept Design.pptx
New Product Concept Design.pptxNew Product Concept Design.pptx
New Product Concept Design.pptx
 
Lean & Agile Essentials
Lean & Agile EssentialsLean & Agile Essentials
Lean & Agile Essentials
 
MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?
MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?
MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?
 
Flow, the Universe and Everything
Flow, the Universe and EverythingFlow, the Universe and Everything
Flow, the Universe and Everything
 
Application architecture jumpstart
Application architecture jumpstartApplication architecture jumpstart
Application architecture jumpstart
 
State of agile 2016
State of agile 2016State of agile 2016
State of agile 2016
 
Lean & Agile DevOps with VSTS and TFS 2015
Lean & Agile DevOps with VSTS and TFS 2015Lean & Agile DevOps with VSTS and TFS 2015
Lean & Agile DevOps with VSTS and TFS 2015
 
Application Architecture Jumpstart
Application Architecture JumpstartApplication Architecture Jumpstart
Application Architecture Jumpstart
 
Agile Metrics That Matter
Agile Metrics That MatterAgile Metrics That Matter
Agile Metrics That Matter
 
Advanced oop laws, principles, idioms
Advanced oop laws, principles, idiomsAdvanced oop laws, principles, idioms
Advanced oop laws, principles, idioms
 
Application architecture jumpstart
Application architecture jumpstartApplication architecture jumpstart
Application architecture jumpstart
 
ADO.NET Entity Framework
ADO.NET Entity FrameworkADO.NET Entity Framework
ADO.NET Entity Framework
 
Windows 8 - The JavaScript Story
Windows 8 - The JavaScript StoryWindows 8 - The JavaScript Story
Windows 8 - The JavaScript Story
 
Windows Azure Jumpstart
Windows Azure JumpstartWindows Azure Jumpstart
Windows Azure Jumpstart
 
Introduction to Windows Azure Virtual Machines
Introduction to Windows Azure Virtual MachinesIntroduction to Windows Azure Virtual Machines
Introduction to Windows Azure Virtual Machines
 
Peering through the Clouds - Cloud Architectures You Need to Master
Peering through the Clouds - Cloud Architectures You Need to MasterPeering through the Clouds - Cloud Architectures You Need to Master
Peering through the Clouds - Cloud Architectures You Need to Master
 
Architecting Scalable Applications in the Cloud
Architecting Scalable Applications in the CloudArchitecting Scalable Applications in the Cloud
Architecting Scalable Applications in the Cloud
 
Windows Azure jumpstart
Windows Azure jumpstartWindows Azure jumpstart
Windows Azure jumpstart
 
Windows Azure Virtual Machines
Windows Azure Virtual MachinesWindows Azure Virtual Machines
Windows Azure Virtual Machines
 
A Force of One - Agile and the Solo Developer
A Force of One - Agile and the Solo DeveloperA Force of One - Agile and the Solo Developer
A Force of One - Agile and the Solo Developer
 

Recently uploaded

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 

Recently uploaded (20)

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 

Code smells and Other Malodorous Software Odors

  • 1. Code Smells and other Malodorous Software Odors Clint Edmonson clint@polarissolutions.com
  • 2.
  • 3. We need to talk…
  • 4. Code Smell Code smell, also known as bad smell in computer programming code, refers to any symptom in the source code of a program that may contain an area of concern. According to Martin Fowler, "a code smell is a surface indication that usually corresponds to a deeper problem in the system". https://en.wikipedia.org/wiki/Code_smell
  • 5. Code Sleuth • A smell is by definition something that's quick to spot - or sniffable • Smells don't always indicate a problem • The best smells are easy to spot and most of time lead you to really interesting problems • It's easy for inexperienced people to spot them, even if they don't know enough to evaluate if there's a real problem or to correct them Martin Fowler https://www.martinfowler.com/bliki/CodeSmell.html
  • 7.
  • 8. Low Value Comments Comments that don’t enhance understanding of the code. Comments add value when: • They describe the purpose of the code (why), not the what or how • Explain the steps in an algorithm
  • 9.
  • 10. Dead Code Large blocks of code commented out and/or methods and classes that are left in the code but no longer used in favor of newer functionality. Dead code makes it harder to understand and maintain the system. Quick fix: • DELETE IT! • If we ever want to see it again, we can look it up in source control history.
  • 11.
  • 12. Marathon Methods If it’s more than a screenful, its too much! Some guidance: • A method should have AT MOST 10-12 steps • Extract large blocks into their own methods • You will OFTEN find duplicated code • A good looking method should look like the steps in a recipe book
  • 13.
  • 14. Magic Numbers & Strings Hard coded numbers and string values inside methods. Generally based on an assumption or implicit knowledge and frequently duplicated in multiple places. Very susceptible to fat-fingering errors. Remedies: • Refactor to enums and use implicit conversions to ints or strings when absolutely needed • Consolidate down to static and read-only class fields and properties • Strive to make the application data driven through a config or settings component
  • 15.
  • 16. Duplicate/Triplicate Code Code fragments that look almost identical. Could occur when multiple work on a code base and are unware of existing code that could be used or refactored to be re-used. Also occurs in haste when trying to meet a deadline and unable to resist the temptation to copy and tweak a working class or method. Advice: • Refactoring is NOT something you do later! You are making things worse. • ALWAYS use the Red-Green-Refactor cycle when coding • You are a professional developer - make sure the code you are checking in is the BEST work you can do and you would be proud to show someone else.
  • 17.
  • 18. The Blob Class Lots of methods and properties, making the code difficult to read, understand, and troubleshoot. Often indicates that the class contains too many responsibilities. Remedies: • Can the large class be restructured or broken into smaller classes? • Use the Class Responsibility Collaborator (CRC) card exercise to discover a better OO model
  • 19.
  • 20. Speculative Code Tutorial, experimental or research code checked into the production code base. Code semantics are frequently different from the problem being solved. Advice: • If you are exploring a solution or learning a new technique, do it in a blank project or private branch until you are satisfied that it solves your design problem • Re-implement it in the production code base using intent-driven development
  • 21.
  • 22. Not Invented Here (NIH) Syndrome Code that re-invents the wheel. Pursuit of an interesting problem trumps the needs of the project. The right thing to do: • Leverage well known, documented frameworks • Avoid creating your own Rube Goldberg machine
  • 23. Stack Overflow Programming Trusting someone else’s code to solve your problem without truly understanding how and/or why it works. Solution: • Practice intent-driven development • Code with intent and purpose • Understand EVERY line of code you write
  • 24. And many, many more… Wikipedia • https://en.wikipedia.org/wiki/Code_smell Sourcemaking online lessons • https://sourcemaking.com/refactoring/smells Smells to Refactorings • http://www.industriallogic.com/wp- content/uploads/2005/09/smellstorefactorings.pdf
  • 25. Homework Assignment • Solution Sprawl • Leaky Abstraction • Inappropriate Intimacy • Indecent Exposure • 7 Layer Cake • Uncommunicative Name • Inconsistent Naming
  • 26. Where do these smells come from?
  • 27. Primal Forces • Haste – sacrificing integrity for expedience • Sloth – making poor decisions based on the “easy” answer • Apathy – not caring about solving known problems • Narrow-mindedness – refusal to practice widely-known solutions • Avarice – putting own intellectual pursuits above the needs of the problem at hand • Ignorance – failing to seek understanding before solving a problem • Pride – inventing new designs when existing solutions could readily be applied (NIH syndrome)
  • 28. What do we do about them?
  • 29. //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // // Changes to this file may cause incorrect behavior and // will be lost if the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------
  • 30. Don’t be a tool! Practice Intent Driven Development!
  • 31. Thank You! Clint Edmonson clint@polarissolutions.com Drop by the booth or visit us online at https://polarissolutions.com

Editor's Notes

  1. A code smell, also known as bad smell in computer programming code, refers to any symptom in the source code of a program that possibly indicates a deeper problem. Join us in this lively session where we will get a whiff of some aromas encountered in the field and how we can neutralize them.
  2. Credits: Flickr Creative Commons Nosy by Just Add Light https://www.flickr.com/photos/gnas/4534576312/in/photolist-7UGTyd-251bvvD-9jfETJ-nXm53F-5N5JAz-dxpYxK-fPzjhG-9yiFZe-fzfuAF-9kdqAn-fPzjsf-fPzisj-fPziwU-7Ay8sM-fPziH3-fPziX7-c5R6cj-fPhKM8-fPhKKK-a73Jve-iXFT5e-aaJjr1-9n9YFz-72nBBj-7MNSqN-7U46yV-2zHyhh-9yePL7-cU59m-5yfUY6-P3V8cy-fPhLiF-bfaRjX-fPhKRF-8Vc4z4-9nq4nL-fPhM1V-fPhL8R-9jfEQG-fPhLcX-fPhLKv-fPhKXD-6Mo9gZ-fPzj2L-7ZTQ3e-fPhKYR-fPziF7-fPhLdp-6MqCTU-fPziWh/
  3. 7 Layer Cake – Deep class inheritance hierarchies, conventional wisdom says getting more than 6 or 7 levels deep is a result of over analysis, especially if there are intermediate classes in the tree that are never instantiate and could be collapsed.