SlideShare a Scribd company logo
1 of 96
Download to read offline
Smell your Code!

  Yaser Sulaiman




                   1
2
Our road map




               3
Who?   What?   Why?   How?




                             4
If you can take away only 1 lesson…




                                 5
Don’t Repeat Yourself!




                         6
This rule is so important…




                             7
I must break it!




                   8
Don’t Repeat Yourself!




                         9
Who?   What?   Why?   How?




                             10
“Who are you?”




                 11
A scientist, not an engineer

(I probably should be doing this @ ACM, not IET)




                                            12
13
14
15
16
17
18
19
20
logo stolen from Kyle Usbeck   21
logo by Yukihiro Matsumoto   22
“You talkin’ to me?”




                       23
Are you a software developer?




                                24
If not, do you write code?




                             25
If not, would you be remotely
interested in writing cleaner code
   and making your life easier?



                                26
If not, you’re free to zone out




                                  27
“Why should I listen to you?”




                                28
I won’t give you the “I’m a
passionate software developer” BS



                               29
I’ve a terminal illness




                          30
Make that 2 terminal illnesses




                                 31
Perfectionism
      &
    OCD



                32
photo by X.u.k.i   33
Who?   What?   Why?   How?




                             34
“Code smells?! Can I smell my
          code?!”



                                35
photo by lanceball   36
Yes you can, but not with your nose




                                 37
Code smells are warning signs




                                38
photo by pj_in_oz   39
They’re surface indications of
      deeper problems



                                 40
photo by BenChenowethWork   41
They’re surface indications of
      deeper problems



                                 42
A code smell ⇏ a problem




                           43
Who?   What?   Why?   How?




                             44
The bigger picture




                     45
Software
 Quality


Code Quality




   Code Smells




 not to scale    46
Writing HQ code should be the
          priority



                                47
read
HQ code = easy to understand
                    change



                               48
In the short term, HQ code may
           cost more



                             49
photo by theresaanna   50
Easier to change ≈ less costly




                                 51
In the long run, HQ code costs less




                                 52
One path to cleaner code goes
    through code smells



                                53
Who?   What?   Why?   How?




                             54
There’re many code smells




                            55
The following smells are just a small
               subset



                                  56
They’re the ones that drives me
        crazy the most



                                  57
Code Smell #1




                58
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
                              59
The nastiest code smell




                          60
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
DupIicated code DupIicated code
                              61
Code Smell #2




                62
functions.With(just, way,
too, many, parameters, and,
  then, even, some, more)



                          63
How many is too many?




                        64
Steve McConnell:
     >7±2



                   65
Robert C. “Uncle Bob” Martin:
             >3



                                66
Code Smell #3




                67
Not following a coding
convention/standard/style
       consistently



                            68
stolen from EmacsWiki   69
Not following a coding
convention/standard/style
       consistently



                            70
The specifics doesn’t really matter;
 what matters most is consistency



                                  71
Code Smell #4




                72
// code.CommentOut();




                        73
Don’t get me wrong




                     74
When you’re experimenting,
comment code to your heart's
          content



                               75
Just remember to clean up after
          yourself



                              76
And don’t commit commented-out
              code



                            77
“Commented-out code is an
abomination.”—Uncle Bob
     photo used with permission of Uncle Bob   78
Commented-out code makes Uncle
         Bob angry



                            79
It makes me angry




                    80
photo by tomazstolfa   81
Code Smell #5




                82
redundant

// This is a comment




                       83
Comments
should focus on


        Who?   What?   Why?   How?




                                     84
Who?   What?   Why?   How?




                             85
I may have come off as an a$$




                                86
My code smells as bad as everyone
 else’s.. sometimes even worse



                               87
But I’m aware of my smells




                             88
I try my best to prevent them




                                89
I don’t ignore them; I deal with
             them



                                   90
I smell my code




                  91
You should smell your code too




                                 92
When you code, take note of your nose
       It should be open, not close
 For an open nose leads to an open mind
And that’s the best rhyme I was able to find



                                         93
If you want to sniff more…




                             94
more than just code smells   95
…</presentation>
  <questions>…



                   96

More Related Content

Viewers also liked

Refactor your Java EE application using Microservices and Containers - Arun G...
Refactor your Java EE application using Microservices and Containers - Arun G...Refactor your Java EE application using Microservices and Containers - Arun G...
Refactor your Java EE application using Microservices and Containers - Arun G...Codemotion
 
Refactoring 101
Refactoring 101Refactoring 101
Refactoring 101Adam Culp
 
Perfect Styling - How to write better CSS
Perfect Styling - How to write better CSSPerfect Styling - How to write better CSS
Perfect Styling - How to write better CSSArtem Tabalin
 
Smells Like Teen Spirit: Improving Bug Prediction Performance using the Inten...
Smells Like Teen Spirit: Improving Bug Prediction Performance using the Inten...Smells Like Teen Spirit: Improving Bug Prediction Performance using the Inten...
Smells Like Teen Spirit: Improving Bug Prediction Performance using the Inten...Fabio Palomba
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy CodeAdam Culp
 
Refactoring - An Introduction
Refactoring - An IntroductionRefactoring - An Introduction
Refactoring - An IntroductionGiorgio Vespucci
 
An Introduction to OAuth2
An Introduction to OAuth2An Introduction to OAuth2
An Introduction to OAuth2Aaron Parecki
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerIgor Crvenov
 
Refactoring: Improve the design of existing code
Refactoring: Improve the design of existing codeRefactoring: Improve the design of existing code
Refactoring: Improve the design of existing codeValerio Maggio
 
I can smell your CMS
I can smell your CMSI can smell your CMS
I can smell your CMSR/GA
 
Securing RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID ConnectSecuring RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID ConnectJonathan LeBlanc
 
Rest API Security
Rest API SecurityRest API Security
Rest API SecurityStormpath
 
Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)Stormpath
 

Viewers also liked (18)

Data Class - Bad smells
Data Class - Bad smellsData Class - Bad smells
Data Class - Bad smells
 
Code smells
Code smellsCode smells
Code smells
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Smell
SmellSmell
Smell
 
Refactor your Java EE application using Microservices and Containers - Arun G...
Refactor your Java EE application using Microservices and Containers - Arun G...Refactor your Java EE application using Microservices and Containers - Arun G...
Refactor your Java EE application using Microservices and Containers - Arun G...
 
Refactoring 101
Refactoring 101Refactoring 101
Refactoring 101
 
Perfect Styling - How to write better CSS
Perfect Styling - How to write better CSSPerfect Styling - How to write better CSS
Perfect Styling - How to write better CSS
 
Smells Like Teen Spirit: Improving Bug Prediction Performance using the Inten...
Smells Like Teen Spirit: Improving Bug Prediction Performance using the Inten...Smells Like Teen Spirit: Improving Bug Prediction Performance using the Inten...
Smells Like Teen Spirit: Improving Bug Prediction Performance using the Inten...
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy Code
 
Refactoring - An Introduction
Refactoring - An IntroductionRefactoring - An Introduction
Refactoring - An Introduction
 
An Introduction to OAuth2
An Introduction to OAuth2An Introduction to OAuth2
An Introduction to OAuth2
 
JavaScript Refactoring
JavaScript RefactoringJavaScript Refactoring
JavaScript Refactoring
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin Fowler
 
Refactoring: Improve the design of existing code
Refactoring: Improve the design of existing codeRefactoring: Improve the design of existing code
Refactoring: Improve the design of existing code
 
I can smell your CMS
I can smell your CMSI can smell your CMS
I can smell your CMS
 
Securing RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID ConnectSecuring RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID Connect
 
Rest API Security
Rest API SecurityRest API Security
Rest API Security
 
Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)Secure Your REST API (The Right Way)
Secure Your REST API (The Right Way)
 

Similar to Smell your Code! @ IET-KFUPM PATW

Smell your Code! @ Free Dimension
Smell your Code! @ Free DimensionSmell your Code! @ Free Dimension
Smell your Code! @ Free DimensionYaser Sulaiman
 
Finding Inspiration From Environment
Finding Inspiration From EnvironmentFinding Inspiration From Environment
Finding Inspiration From EnvironmentNick La
 
Think Devlish act Angelic - Search Love 2012
Think Devlish act Angelic - Search Love 2012Think Devlish act Angelic - Search Love 2012
Think Devlish act Angelic - Search Love 2012Wil Reynolds
 
Code review in practice
Code review in practiceCode review in practice
Code review in practiceEdorian
 
Talk ja ye-nuno_freitas_1set2012
Talk ja ye-nuno_freitas_1set2012Talk ja ye-nuno_freitas_1set2012
Talk ja ye-nuno_freitas_1set2012Nuno Freitas
 
D3034 us memoryjogger
D3034 us memoryjoggerD3034 us memoryjogger
D3034 us memoryjoggerShawnna South
 
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010Atlassian
 
Education for Design For Life
Education for Design For LifeEducation for Design For Life
Education for Design For LifeDave Malouf
 
Lessons from Testing
Lessons from TestingLessons from Testing
Lessons from TestingJon Jagger
 
Proposals for the Reborn Pharo Developer
Proposals for the Reborn Pharo DeveloperProposals for the Reborn Pharo Developer
Proposals for the Reborn Pharo DeveloperESUG
 
Logo design love_free_chapter
Logo design love_free_chapterLogo design love_free_chapter
Logo design love_free_chapterbedu beda
 
Code Excellence for the Average Programmer
Code Excellence for the Average ProgrammerCode Excellence for the Average Programmer
Code Excellence for the Average ProgrammerLlewellyn Falco
 

Similar to Smell your Code! @ IET-KFUPM PATW (13)

Smell your Code! @ Free Dimension
Smell your Code! @ Free DimensionSmell your Code! @ Free Dimension
Smell your Code! @ Free Dimension
 
Finding Inspiration From Environment
Finding Inspiration From EnvironmentFinding Inspiration From Environment
Finding Inspiration From Environment
 
Think Devlish act Angelic - Search Love 2012
Think Devlish act Angelic - Search Love 2012Think Devlish act Angelic - Search Love 2012
Think Devlish act Angelic - Search Love 2012
 
Code review in practice
Code review in practiceCode review in practice
Code review in practice
 
Talk ja ye-nuno_freitas_1set2012
Talk ja ye-nuno_freitas_1set2012Talk ja ye-nuno_freitas_1set2012
Talk ja ye-nuno_freitas_1set2012
 
D3034 us memoryjogger
D3034 us memoryjoggerD3034 us memoryjogger
D3034 us memoryjogger
 
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
 
Education for Design For Life
Education for Design For LifeEducation for Design For Life
Education for Design For Life
 
Lessons from Testing
Lessons from TestingLessons from Testing
Lessons from Testing
 
2009 777 Panel - Staying Relevant
2009 777 Panel - Staying Relevant2009 777 Panel - Staying Relevant
2009 777 Panel - Staying Relevant
 
Proposals for the Reborn Pharo Developer
Proposals for the Reborn Pharo DeveloperProposals for the Reborn Pharo Developer
Proposals for the Reborn Pharo Developer
 
Logo design love_free_chapter
Logo design love_free_chapterLogo design love_free_chapter
Logo design love_free_chapter
 
Code Excellence for the Average Programmer
Code Excellence for the Average ProgrammerCode Excellence for the Average Programmer
Code Excellence for the Average Programmer
 

Recently uploaded

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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 2024The Digital Insurer
 
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...Martijn de Jong
 
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 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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 CVKhem
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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.pdfsudhanshuwaghmare1
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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...Drew Madelung
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Recently uploaded (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
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...
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Smell your Code! @ IET-KFUPM PATW