Your SlideShare is downloading. ×
  • Like
  • Save
Slides for Houston iPhone Developers' Meetup (April 2012)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Slides for Houston iPhone Developers' Meetup (April 2012)

  • 394 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
394
On SlideShare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Caring About YourObjective-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 toread, and only incidentally for machines toexecute. 4
  • 5. Code Quality (2/3)Image Source: 5http://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 thesoftware 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
  • 20. Clang Static Analyzer Demo 20
  • 21. JetBrains AppCode• On-the-fly code analysis• Code inspection• http://www.jetbrains.com/objc/ 21
  • 22. AppCode Demo 22
  • 23. OCLint• Improve quality• Reduce defects• http://oclint.org 23
  • 24. OCLint Demo 24
  • 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
  • 27. Refactoring Demo 27
  • 28. Questions? 28
  • 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