Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Code Review: How and When

137 views

Published on

You want to improve your software skills. That’s a given. You may be a mentor or a manager who needs to improve the knowledge sharing among your software developers across different projects. Code Reviews can do just that while improving code quality in your projects. Code Review not only builds developer team spirit but also offers new ways to improve a software solution. You’ll walk away from this session with in-depth understanding of Code Review to strengthen your team.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Code Review: How and When

  1. 1. Code Review How And When @paulmgower
  2. 2. I’m Paul Gower. Principal Consultant at Lunamark @paulmgower
  3. 3. AGENDA What Is Code Review1 2 3 How and When Why Code Review
  4. 4. What Is Code Review 1
  5. 5. Father of Code Review http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5388086&filter%3DAND%28p_IS_Number%3A5388084%29 aka Fagan Inspections
  6. 6. Fagan Inspections https://en.wikipedia.org/wiki/Fagan_inspection
  7. 7. Code Review History
  8. 8. Why Use Fagan Inspections?
  9. 9. Why Use Fagan Inspections? Good for Mission Critical Software
  10. 10. Lightweight Code Reviews https://en.wikipedia.org/wiki/Code_review
  11. 11. Over-the-shoulder
  12. 12. Email pass-around
  13. 13. Email pass-around Please don’t do this!
  14. 14. Pair Programming
  15. 15. Code Review Tools
  16. 16. Code Review Tool Resources • github reviews - https://github.com/universe-2016#reviews • video demo - https://www.youtube.com/watch?v=HW0RPaJqm4g • reviewable - https://reviewable.io/ • demo - https://reviewable.io/reviews/Reviewable/demo/1 • gerrit code review - https://www.gerritcodereview.com • tutorial - http://www.vogella.com/tutorials/Gerrit/article.html • VSTS Code Review (TFVC) - https://www.visualstudio.com/en-us/docs/ tfvc/get-code-reviewed-vs • walk through - https://www.visualstudio.com/en-us/docs/tfvc/day-life- alm-developer-suspend-work-fix-bug-conduct-code-review
  17. 17. • Review Assistant - https://www.devart.com/review-assistant/ • comparison - https://www.devart.com/review-assistant/learnmore/ visual-studio-vs-review-assistant.html • Crucible - https://www.atlassian.com/software/crucible • video demo - https://www.youtube.com/watch?v=UFNPgfQFJHk • Collaborator - https://smartbear.com/product/collaborator/overview/ • video demo - https://www.youtube.com/watch?v=1MBb21DgRYg • FogBugz Dev Hub - http://www.fogcreek.com/fogbugz/devhub • demo - http://www.joelonsoftware.com/items/2011/02/03.html Code Review Tool Resources
  18. 18. How and When 2
  19. 19. Reviewer: Focus on the code
  20. 20. Reviewer: Focus on the code Don’t say: “You didn’t name these variables well!”
  21. 21. Reviewer: Focus on the code Don’t say: “You didn’t name these variables well!” Instead: “I don’t understand these variable names, can you help me understand them?”
  22. 22. Reviewer: Be respectful
  23. 23. Reviewer: Find a positive point
  24. 24. How NOT to Code Review
  25. 25. Author: Be humble
  26. 26. Author: Prepare Before
  27. 27. “ “The objective is for everyone to find defects, including the author, not to prove the work product has no defects. People exchange work products to review, with the expectation that as authors, they will produce errors, and as reviewers, they will find errors. Everyone ends up learning from their own mistakes and other people’s mistakes.” – Jerry Weinberg, “The Psychology of Computer Programming”, 1971
  28. 28. Tips and Tricks
  29. 29. Less Than 200 Lines Of Code
  30. 30. Less Than 60 Minutes
  31. 31. Less Than 60 Minutes http://www.news.illinois.edu/news/11/0208focus_AlejandroLleras.html
  32. 32. Daily Code Review
  33. 33. Daily Code Review http://blog.fogcreek.com/effective-code-reviews-9-tips-from-a-converted-skeptic/
  34. 34. Always Use A Checklist http://www.codeproject.com/Articles/593751/Code-Review-Checklist-and-Guidelines-for-Csharp-De
  35. 35. Developer Checklist • Does my code compile without errors and run without exceptions in “happy path” conditions? • Have I checked this code to see if it triggers compiler or static analysis warnings? • Have I covered this code with appropriate tests, and are those test currently green? • Have I run our performance/load/smoke tests to make sure nothing I’ve introduced is a performance killer? http://blog.smartbear.com/code-review/creating-your-code-review-checklist/
  36. 36. Reviewer Checklist • Does this code read like prose? • Do the methods do what the name of the method claims that they’ll do? Same for classes? • Can I get an understanding of the desired behavior just by doing quick scans through unit and acceptance tests? • Is anything here a re-implementation of existing functionality the developer may not be aware of? http://blog.smartbear.com/code-review/creating-your-code-review-checklist/
  37. 37. Don’t Be This Guy
  38. 38. Don’t Review What Can Be Automated
  39. 39. Static Code Analysis Tools
  40. 40. https://www.npmjs.com/package/eslint-watch
  41. 41. Static Code Analysis Resources • JSLint - http://www.jslint.com • video demo - https://www.youtube.com/watch?v=QWjMZBoSBtQ • JSHint - http://jshint.com • video demo - https://www.youtube.com/watch?v=MvV6fljX538 • ESLint - http://eslint.org • video demo - https://www.youtube.com/watch?v=L6vMey4FtQ0 • StyleCop - https://stylecop.codeplex.com • video demo - https://www.youtube.com/watch?v=6v8_PdePM7M • Visual Studio Code Analysis - https://msdn.microsoft.com/en-us/library/ 3z0aeatx.aspx • walkthrough - https://msdn.microsoft.com/en-us/library/ms182066.aspx • ReSharper - https://www.jetbrains.com/resharper/ • demo - https://www.youtube.com/watch?v=jq1JDlIiRmg
  42. 42. 3 Why Code Review
  43. 43. “ “…the average defect detection rate is only 25 percent for unit testing, 35 percent for function testing, and 45 percent for integration testing. In contrast, the average effectiveness of design and code inspections are 55 and 60 percent.” - Steve McConnell, Code Complete, 2004
  44. 44. Before 55% Code Review Case Studies
  45. 45. Before After 2% 55% Code Review Case Studies
  46. 46. Before Code Reviews
  47. 47. After Code Reviews
  48. 48. Reasons to Code Review
  49. 49. Save Money
  50. 50. Easier To Find Other’s Mistakes
  51. 51. Alternative Implementations
  52. 52. Knowledge Sharing
  53. 53. “ “The aim is to catch what mistakes you can and to get better – not to attempt perfection.” - Erik Dietrich, “Creating Your Code Review Checklist”, 2015
  54. 54. Review • No more than 60 mins • No more than 200 lines of code • Use Static Code Analysis • Use Check Lists • Use A Code Review Tool
  55. 55. THANK YOU! @paulmgower bit.ly/lrtf2016-cr lunamark.com

×