SlideShare una empresa de Scribd logo
1 de 96
Descargar para leer sin conexión
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

Más contenido relacionado

Destacado

Destacado (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 a Smell your Code! @ IET-KFUPM PATW

D3034 us memoryjogger
D3034 us memoryjoggerD3034 us memoryjogger
D3034 us memoryjogger
Shawnna South
 

Similar a 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
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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...
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - 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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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...
 
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...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Smell your Code! @ IET-KFUPM PATW