SlideShare a Scribd company logo
1 of 30
Caring About Your
Objective-C Code Quality
        Longyi Qi



         April 17, 2012
                           1
• Graduate Student
  Computer Science, University of Houston
  Advisor: Dr. Venkat Subramaniam
• Mobile and Web Developer
  ChaiONE
• http://www.longyiqi.com
  lqi@longyiqi.com
  @longyiqi

                                            2
Why Care About Code Quality?
• We keep changing and evolving our software
  based on feedback, if our code quality is poor,
  it’s hard to do so.
• A high code quality is a very important aspect
  that leads to a success app.




                                                    3
Code Quality (1/3)
Programs should be written for people to
read, and only incidentally for machines to
execute.




                                              4
Code Quality (2/3)




Image Source:                                                                          5
http://www.gridshore.nl/2008/12/30/defects-lean-software-development-offshore-oh-my/
Code Quality (3/3)
Quality is a measurement of how well the
software is designed and implemented.

Who cares?




                                           6
First Law of Programming
• Lowering quality lengthens development time.
• Agile development is a long-term gain
• Keep codebase healthy




                                                 7
Software Defect Reduction Top 10 List (1/2)

• Finding and fixing a software problem after delivery is
  often 100 times more expensive than finding and fixing
  it during the requirements and design phase
• Current software projects spend about 40 to 50 percent
  of their effort on avoidable rework.
• About 80 percent of avoidable rework comes from 20
  percent of the defects.
• About 80 percent of the defects come from 20 percent
  of the modules, and about half the modules are defect
  free.
• About 90 percent of the downtime comes from, at most,
  10 percent of the defects.

                                                       8
Software Defect Reduction Top 10 List (2/2)

• Peer reviews catch 60 percent of the defects.
• Perspective-based reviews catch 35 percent more defects
  than non directed reviews.
• Disciplined personal practices can reduce defect
  introduction rates by up to 75 percent.
• All other things being equal, it costs 50 percent more per
  source instruction to develop high-dependability software
  products than to develop low-dependability software
  products. However, the investment is more than worth it if
  the project involves significant operations and maintenance
  costs.
• About 40 to 50 percent of user programs contain nontrivial
  defects.

                                                                9
Technical Debt
• All comprises in software development are
  technical debts
  – Don’t update dependent libraries
  – Postpone code refactoring
  – Write “quick and dirty” code to meet deadline
• As soon as a technical debt is owed, the
  interests will incur.


                                                    10
Broken Window Theory
• If there is a broken window in the building,
  and nobody repairs it for a while, it could
  arouse the feeling of being abandoned.
• Gradually, more and more windows get
  broken.
• Consequently, this type of disorder leads to
  additional crimes and anti-social behaviors.


                                                 11
Measure Quality
• Is code simple enough?
• Is code easy to read?
• Is code easy to understand?
• Is method size small?
• Is class size small?
• Are variable names, method names, class names
  meaningful?
• Is the code testable? Has tests?
• Is code following code standard? Code
  convention?
                                                  12
Code Smells
• Code smells are symptoms that indicate deeper
  problems in the source code.




                                              13
Code Smell Samples
•   Duplicated code
•   Constant if statement
•   Unreachable code
•   Long method
•   High cyclomatic complexity
•   …



                                 14
Dealing with Code Smells
• Keep an eye on it
• Indicate code that needs either refactoring or
  some serious redesign
• Pay off technical debts
• Take effort to clear the air frequently




                                                   15
Code Analysis
• Code reviews
• Pair programming
• Static code analysis




                             16
Static Code Analysis
• Examines the source code and identifies the
  problems without running the program.




                                                17
Static Code Analysis Tools
• Observe source code, match against predefined
  error patterns, and indicate potential errors.
• Objective-C Static Code Analysis Tools
  – Clang Static Analyzer
  – JetBrains AppCode
  – OCLint




                                               18
Clang Static Analyzer
• Apple LLVM compiler infrastructure team
• http://clang-analyzer.llvm.org/
• Xcode IDE integration




                                            19
Clang Static Analyzer Demo




                             20
JetBrains AppCode
• On-the-fly code analysis
• Code inspection
• http://www.jetbrains.com/objc/




                                   21
AppCode Demo




               22
OCLint
• Improve quality
• Reduce defects
• http://oclint.org




                               23
OCLint Demo




              24
Code Refactoring
• The process of changing a software system
• Does not alter the external behavior of the
  code
• Improves its internal structure




                                                25
Ultimate Goal of Refactoring Code
•   Simplicity
•   Clarity
•   Brevity
•   Humanity

--- William Zinsser, On Writing Well




                                       26
Refactoring Demo




                   27
Questions?




             28
OCLint Future Work
•   Accuracy and false positive
•   Better code quality inspections
•   Extended rules
•   Compatibility
•   Performance
•   User experiences
•   IDE integrations

                                      29
Thank You!
• Contact OCLint Project
  http://oclint.org
  @oclint_project
  longyi@oclint.org
• Contact Longyi Qi
  http://www.longyiqi.com
  @longyiqi
  lqi@longyiqi.com



                             30

More Related Content

What's hot

IP Reuse Impact on Design Verification Management Across the Enterprise
IP Reuse Impact on Design Verification Management Across the EnterpriseIP Reuse Impact on Design Verification Management Across the Enterprise
IP Reuse Impact on Design Verification Management Across the Enterprise
DVClub
 

What's hot (20)

CS519 - Visual Software Evolution Reconstruction
CS519 - Visual Software Evolution ReconstructionCS519 - Visual Software Evolution Reconstruction
CS519 - Visual Software Evolution Reconstruction
 
CODE REVIEW AND COOPERATIVE PAIR PROGRAMMING BEST PRACTICE
CODE REVIEW AND COOPERATIVE PAIR PROGRAMMING BEST PRACTICECODE REVIEW AND COOPERATIVE PAIR PROGRAMMING BEST PRACTICE
CODE REVIEW AND COOPERATIVE PAIR PROGRAMMING BEST PRACTICE
 
Reducing Technical Debt
Reducing Technical DebtReducing Technical Debt
Reducing Technical Debt
 
Software Design
Software DesignSoftware Design
Software Design
 
Agile Austin - Peer Code Review An Agile Process
Agile Austin -  Peer Code Review An Agile ProcessAgile Austin -  Peer Code Review An Agile Process
Agile Austin - Peer Code Review An Agile Process
 
Code Review and other aspects of project organization
Code Review and other aspects of project organizationCode Review and other aspects of project organization
Code Review and other aspects of project organization
 
CS519 - Cloud Twin: Native Execution of Android Applications on the Windows P...
CS519 - Cloud Twin: Native Execution of Android Applications on the Windows P...CS519 - Cloud Twin: Native Execution of Android Applications on the Windows P...
CS519 - Cloud Twin: Native Execution of Android Applications on the Windows P...
 
IS3242 Case Presentation
IS3242 Case PresentationIS3242 Case Presentation
IS3242 Case Presentation
 
codEnforcer 2013
codEnforcer 2013codEnforcer 2013
codEnforcer 2013
 
Importance of the quality of code
Importance of the quality of codeImportance of the quality of code
Importance of the quality of code
 
Big Ball of Mud: Software Maintenance Nightmares
Big Ball of Mud: Software Maintenance NightmaresBig Ball of Mud: Software Maintenance Nightmares
Big Ball of Mud: Software Maintenance Nightmares
 
The Next Static Code Analysis Tool - Today and Tomorrow
The Next Static Code Analysis Tool - Today and TomorrowThe Next Static Code Analysis Tool - Today and Tomorrow
The Next Static Code Analysis Tool - Today and Tomorrow
 
Quick Intro to Clean Coding
Quick Intro to Clean CodingQuick Intro to Clean Coding
Quick Intro to Clean Coding
 
Back to the Basics: Principles for Constructing Quality Software
Back to the Basics: Principles for Constructing Quality SoftwareBack to the Basics: Principles for Constructing Quality Software
Back to the Basics: Principles for Constructing Quality Software
 
Agile code quality metrics
Agile code quality metricsAgile code quality metrics
Agile code quality metrics
 
IP Reuse Impact on Design Verification Management Across the Enterprise
IP Reuse Impact on Design Verification Management Across the EnterpriseIP Reuse Impact on Design Verification Management Across the Enterprise
IP Reuse Impact on Design Verification Management Across the Enterprise
 
CS 584 - Aligning development tools with the way programmers think about code...
CS 584 - Aligning development tools with the way programmers think about code...CS 584 - Aligning development tools with the way programmers think about code...
CS 584 - Aligning development tools with the way programmers think about code...
 
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
 
Agile principles and practices
Agile principles and practicesAgile principles and practices
Agile principles and practices
 
Code Quality Lightning Talk
Code Quality Lightning TalkCode Quality Lightning Talk
Code Quality Lightning Talk
 

Viewers also liked (11)

Optimization in Programming languages
Optimization in Programming languagesOptimization in Programming languages
Optimization in Programming languages
 
C optimization notes
C optimization notesC optimization notes
C optimization notes
 
Code Optimization using Code Re-ordering
Code Optimization using Code Re-orderingCode Optimization using Code Re-ordering
Code Optimization using Code Re-ordering
 
Introduction to code optimization by dipankar
Introduction to code optimization by dipankarIntroduction to code optimization by dipankar
Introduction to code optimization by dipankar
 
Optimization
OptimizationOptimization
Optimization
 
optimization c code on blackfin
optimization c code on blackfinoptimization c code on blackfin
optimization c code on blackfin
 
Objective C for Samurais
Objective C for SamuraisObjective C for Samurais
Objective C for Samurais
 
sCode optimization
sCode optimizationsCode optimization
sCode optimization
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Embedded C - Optimization techniques
Embedded C - Optimization techniquesEmbedded C - Optimization techniques
Embedded C - Optimization techniques
 
Protein Structure & Function
Protein Structure & FunctionProtein Structure & Function
Protein Structure & Function
 

Similar to Slides for Houston iPhone Developers' Meetup (April 2012)

Blackboard DevCon 2012 - Ensuring Code Quality
Blackboard DevCon 2012 - Ensuring Code QualityBlackboard DevCon 2012 - Ensuring Code Quality
Blackboard DevCon 2012 - Ensuring Code Quality
Noriaki Tatsumi
 
Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applications
nadeembtech
 
ppt_se.bdfhrfykjyftiktgdukhydiyiuoyu8otrfu
ppt_se.bdfhrfykjyftiktgdukhydiyiuoyu8otrfuppt_se.bdfhrfykjyftiktgdukhydiyiuoyu8otrfu
ppt_se.bdfhrfykjyftiktgdukhydiyiuoyu8otrfu
tubashaikh26
 
Clean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampClean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code Camp
Theo Jungeblut
 

Similar to Slides for Houston iPhone Developers' Meetup (April 2012) (20)

Technical debt management strategies
Technical debt management strategiesTechnical debt management strategies
Technical debt management strategies
 
Automation and Technical Debt
Automation and Technical DebtAutomation and Technical Debt
Automation and Technical Debt
 
Code Reviews
Code ReviewsCode Reviews
Code Reviews
 
Software Quality via Unit Testing
Software Quality via Unit TestingSoftware Quality via Unit Testing
Software Quality via Unit Testing
 
Blackboard DevCon 2012 - Ensuring Code Quality
Blackboard DevCon 2012 - Ensuring Code QualityBlackboard DevCon 2012 - Ensuring Code Quality
Blackboard DevCon 2012 - Ensuring Code Quality
 
Aliaksei Skobeleu "Taking Control Over Code Metrics"
Aliaksei Skobeleu "Taking Control Over Code Metrics"Aliaksei Skobeleu "Taking Control Over Code Metrics"
Aliaksei Skobeleu "Taking Control Over Code Metrics"
 
Software Defect Prevention via Continuous Inspection
Software Defect Prevention via Continuous InspectionSoftware Defect Prevention via Continuous Inspection
Software Defect Prevention via Continuous Inspection
 
Programming languages and techniques for today’s embedded andIoT world
Programming languages and techniques for today’s embedded andIoT worldProgramming languages and techniques for today’s embedded andIoT world
Programming languages and techniques for today’s embedded andIoT world
 
Caring about Code Quality
Caring about Code QualityCaring about Code Quality
Caring about Code Quality
 
Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applications
 
5 Ways to Accelerate Standards Compliance with Static Code Analysis
5 Ways to Accelerate Standards Compliance with Static Code Analysis 5 Ways to Accelerate Standards Compliance with Static Code Analysis
5 Ways to Accelerate Standards Compliance with Static Code Analysis
 
ppt_se.bdfhrfykjyftiktgdukhydiyiuoyu8otrfu
ppt_se.bdfhrfykjyftiktgdukhydiyiuoyu8otrfuppt_se.bdfhrfykjyftiktgdukhydiyiuoyu8otrfu
ppt_se.bdfhrfykjyftiktgdukhydiyiuoyu8otrfu
 
ppt_se.pdf
ppt_se.pdfppt_se.pdf
ppt_se.pdf
 
Expert Code Review best practices
Expert Code Review best practicesExpert Code Review best practices
Expert Code Review best practices
 
Automated Code Reviews with AI and ML - DevOps Next
Automated Code Reviews with AI and ML - DevOps NextAutomated Code Reviews with AI and ML - DevOps Next
Automated Code Reviews with AI and ML - DevOps Next
 
The Case for Low-code Development
The Case for Low-code DevelopmentThe Case for Low-code Development
The Case for Low-code Development
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code Review
 
Week1.pptx
Week1.pptxWeek1.pptx
Week1.pptx
 
Clean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampClean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code Camp
 
Architectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and ConsistentlyArchitectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and Consistently
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

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
 
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
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
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...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
[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
 
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)
 
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
 
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...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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?
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Slides for Houston iPhone Developers' Meetup (April 2012)

  • 1. Caring About Your Objective-C Code Quality Longyi Qi April 17, 2012 1
  • 2. • Graduate Student Computer Science, University of Houston Advisor: Dr. Venkat Subramaniam • Mobile and Web Developer ChaiONE • http://www.longyiqi.com lqi@longyiqi.com @longyiqi 2
  • 3. Why Care About Code Quality? • We keep changing and evolving our software based on feedback, if our code quality is poor, it’s hard to do so. • A high code quality is a very important aspect that leads to a success app. 3
  • 4. Code Quality (1/3) Programs should be written for people to read, and only incidentally for machines to execute. 4
  • 5. Code Quality (2/3) Image Source: 5 http://www.gridshore.nl/2008/12/30/defects-lean-software-development-offshore-oh-my/
  • 6. Code Quality (3/3) Quality is a measurement of how well the software is designed and implemented. Who cares? 6
  • 7. First Law of Programming • Lowering quality lengthens development time. • Agile development is a long-term gain • Keep codebase healthy 7
  • 8. Software Defect Reduction Top 10 List (1/2) • Finding and fixing a software problem after delivery is often 100 times more expensive than finding and fixing it during the requirements and design phase • Current software projects spend about 40 to 50 percent of their effort on avoidable rework. • About 80 percent of avoidable rework comes from 20 percent of the defects. • About 80 percent of the defects come from 20 percent of the modules, and about half the modules are defect free. • About 90 percent of the downtime comes from, at most, 10 percent of the defects. 8
  • 9. Software Defect Reduction Top 10 List (2/2) • Peer reviews catch 60 percent of the defects. • Perspective-based reviews catch 35 percent more defects than non directed reviews. • Disciplined personal practices can reduce defect introduction rates by up to 75 percent. • All other things being equal, it costs 50 percent more per source instruction to develop high-dependability software products than to develop low-dependability software products. However, the investment is more than worth it if the project involves significant operations and maintenance costs. • About 40 to 50 percent of user programs contain nontrivial defects. 9
  • 10. Technical Debt • All comprises in software development are technical debts – Don’t update dependent libraries – Postpone code refactoring – Write “quick and dirty” code to meet deadline • As soon as a technical debt is owed, the interests will incur. 10
  • 11. Broken Window Theory • If there is a broken window in the building, and nobody repairs it for a while, it could arouse the feeling of being abandoned. • Gradually, more and more windows get broken. • Consequently, this type of disorder leads to additional crimes and anti-social behaviors. 11
  • 12. Measure Quality • Is code simple enough? • Is code easy to read? • Is code easy to understand? • Is method size small? • Is class size small? • Are variable names, method names, class names meaningful? • Is the code testable? Has tests? • Is code following code standard? Code convention? 12
  • 13. Code Smells • Code smells are symptoms that indicate deeper problems in the source code. 13
  • 14. Code Smell Samples • Duplicated code • Constant if statement • Unreachable code • Long method • High cyclomatic complexity • … 14
  • 15. Dealing with Code Smells • Keep an eye on it • Indicate code that needs either refactoring or some serious redesign • Pay off technical debts • Take effort to clear the air frequently 15
  • 16. Code Analysis • Code reviews • Pair programming • Static code analysis 16
  • 17. Static Code Analysis • Examines the source code and identifies the problems without running the program. 17
  • 18. Static Code Analysis Tools • Observe source code, match against predefined error patterns, and indicate potential errors. • Objective-C Static Code Analysis Tools – Clang Static Analyzer – JetBrains AppCode – OCLint 18
  • 19. Clang Static Analyzer • Apple LLVM compiler infrastructure team • http://clang-analyzer.llvm.org/ • Xcode IDE integration 19
  • 21. JetBrains AppCode • On-the-fly code analysis • Code inspection • http://www.jetbrains.com/objc/ 21
  • 23. OCLint • Improve quality • Reduce defects • http://oclint.org 23
  • 25. Code Refactoring • The process of changing a software system • Does not alter the external behavior of the code • Improves its internal structure 25
  • 26. Ultimate Goal of Refactoring Code • Simplicity • Clarity • Brevity • Humanity --- William Zinsser, On Writing Well 26
  • 29. OCLint Future Work • Accuracy and false positive • Better code quality inspections • Extended rules • Compatibility • Performance • User experiences • IDE integrations 29
  • 30. Thank You! • Contact OCLint Project http://oclint.org @oclint_project longyi@oclint.org • Contact Longyi Qi http://www.longyiqi.com @longyiqi lqi@longyiqi.com 30