Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Code Review is an Architectural Necessity (Winter 2023)

Colin Dean
January 12, 2023

Code Review is an Architectural Necessity (Winter 2023)

Code Review is not a new concept, but a specific term for an older concept -- Peer Review -- that focuses the review process on the code under examination instead of the person who submitted it. While Code Review is common in open source projects, organizations developing in private often employ inefficient, frustrating, or virtually non-existent review processes. This talk looks at Code Review from an architect's viewpoint, arguing that Code Review is an essential component in a product's architectural plan because of the quality attributes it may provide. It also covers tips and sets expectations for what Code Review can and cannot solve.

(This version was closer to 50 minutes and features suggestions not included on previous editions.)

https://www.codemash.org/session-details/?id=380044

Colin Dean

January 12, 2023
Tweet

More Decks by Colin Dean

Other Decks in Technology

Transcript

  1. #codereview My words are my own and not my employer’s,

    past or present. There may be some swearing. Please save questions until the end of the presentation. 3
  2. #codereview Agenda • Quick anecdote • What is code review?

    • What problems does code review solve? • Quality attributes code review ensures • Tips for code reviews • Limitations 4
  3. #codereview Agenda • Quick anecdote • What is code review?

    • What problems does code review solve? • Quality attributes code review ensures • Tips for code reviews • Limitations 6
  4. #codereview Code review is the process by which those who

    maintain a software codebase evaluate a proposed change to that codebase, regardless of the source of the proposed change. 8
  5. #codereview Code Review Vocabulary • Change - an individual unit

    of work altering what exists • Submission - a collection of changes • Submitter - the person proposing the submission • Reviewer - the people evaluating the submission • Annotation - remarks or ratings bestowed upon the submission 13
  6. #codereview The submitter proposes changes in a submission, which is

    evaluated by a reviewer, who annotates or accepts it. 14
  7. Inspection Team review Walkthrough Pair programming Peer deskcheck, passaround Ad-hoc

    review Wiegers’ peer review formality spectrum Least formal Most formal 15
  8. Most formal Least formal Wiegers’ peer review formality spectrum Inspection

    Team review Walkthrough Pair programming Peer deskcheck, passaround Ad-hoc review 16
  9. 17

  10. #codereview Agenda • Quick anecdote • What is code review?

    • What problems does code review solve? • Quality attributes code review ensures • Tips for code reviews • Limitations 18
  11. 21

  12. 22

  13. #codereview Michael Keeling 
 Creating an Architecture Oral History, SATURN

    2012 “Architecture oral history requires that the team is both willing and able to retell the stories and keep the oral history alive.” 26
  14. #codereview Agenda • Quick anecdote • What is code review?

    • What problems does code review solve? • Quality attributes code review ensures • Tips for code reviews • Limitations 31
  15. #codereview Learnability • Developing Code • Patterns & Conventions •

    Risks & Goals • Developing People • Common Vocabulary • Teaching Moments Understandability Serviceability Code review drives Maintainability Learnability 34
  16. Learner Expert Coding Reviewing Coding Reviewing Synchronous Pairing & Teaching

    Exemplary Reading Constructively Critical Evaluation Serendipitous Evaluation of Example Understandability Serviceability Maintainability Learnability 35
  17. #codereview Understandability • Establishes common yet evolving mental model •

    Builds con fi dence in direction and design decisions • Builds tribal knowledge • Bonus: Enables elevator pitch Serviceability Code review drives Maintainability Learnability Understandability 36
  18. #codereview Serviceability • Exposes addressable “gotchas” • Exposes end-user interaction

    points • Establishes consensus on supported work fl ows Maintainability Learnability Understandability Serviceability Code review drives 37
  19. #codereview First programming job out of school - B2B imprinting

    company if($customer == “spacely_sprockets”) { do_something(); } 
 else { cry(); } • Version control! • No code review tooling or process • Minimal pairing • Continuous integration easily circumvented 40
  20. #codereview Second job out of school - Consulting • Lone

    wolf working alongside other lone wolves • No version control in proprietary software with custom “IDE” a.k.a. textarea. • Last modi fi ed and modi fi er only • No process of our own 46
  21. First professional code review experience was group review • Subcontractor

    on government project, 2010-2012 • Lone SME on platform • Borland StarTeam + in house review system • My tools for version control integration • Weekly merge window • Round robin inspection
  22. #codereview Not a pleasant experience • Three to four hour

    weekly round robin inspection • Cutthroat mixture of competing contractors, subcontractors, and employees • Embarrassment galore ‛ Not a learning environment • Immediate defensive posture • “Merge next week” = you failed, possibly delayed project 49
  23. #codereview Effects? • Waste • “Get this over with.” •

    Obstructionism • Plenty of bugs • “I’ll fi x that mistake later.” 54
  24. #codereview Missed opportunities • Accessibility expert was most vocal •

    Project manager was vocal on contractual and HF matters ➡ Both could have reviewed asynchronously • Project was behind ➡ Too many people could say No 55
  25. #codereview Security • Spot vulnerabilities • Teach best practices •

    Filter unnecessary code • YAGNI Code review drives 57
  26. #codereview Agenda • Quick anecdote • What is code review?

    • What problems does code review solve? • Quality attributes code review ensures • Tips for code reviews • Limitations 59
  27. #codereview Tips for thorough code review • Devote time •

    Accept debt • Identify churn • Minimize pedantry • Automate aggressively • Make progress 64
  28. #codereview Major things we look for • Algorithmic complexity •

    Exception & error handling • Exception, class, & variable naming • Logging suf fi ciency & level • Style conformation (automate!) • Long lines & methods • Readability • Single purpose per commit 65
  29. #codereview Agenda • Quick anecdote • What is code review?

    • What problems does code review solve? • Quality attributes code review ensures • Tips for code reviews • Limitations 67
  30. #codereview Agenda • Quick anecdote • What is code review?

    • What problems do code review solve? • Quality attributes code review ensures • Tips for code reviews • Limitations 71
  31. #codereview Code Review is systematic examination of proposed changes to

    a codebase. solves mental model synchronization and tribal knowledge development. ensures maintainability, compliance, & security. must be short, thorough, and automated where possible. will not solve all human problems, but some is better than none. 73
  32. #codereview Attributions • Westminster College picture: https://www. fl ickr.com/photos/westminstercollege/15759678054/in/ album-72157649340620016/

    • “Their fi rst code review” http://classicprogrammerpaintings.tumblr.com/post/142702963264/their- fi rst-code-review- william-frederick • Bass, Len; Paul Clements, and Rick Kazman. Software Architecture in Practice. Addison Wesley, 2013. • Wiegers, Karl E. Peer Reviews in Software. Addison Wesley, 2012. • Cohen, Jason, Steven Teleki, and Eric Brown. Best Kept Secrets of Peer Code Review. Smart Bear Software, 2006. • Wilhelm, Alex and Alexia Tsotsis. Julie Ann Horvath Describes Sexism and Intimidation behind Her Github Exit. TechCruch, 2014 March 15. Retrieved 2016 April 26. http://techcrunch.com/2014/03/15/julie-ann-horvath- describes-sexism-and-intimidation-behind-her-github-exit/ • Baccehlli, Alberto and Christian Bird. Expectations, Outcomes, and Challenges Of Modern Code Review. Proceedings of the International Conference on Software Engineering, Proceedings of the International Conference on Software Engineering, May 2013. • Social media icons from FontAwesome • and others mentioned in the slides 77
  33. #codereview Speci fi c tools for eliminating gotchas • pre-commit.com

    • github.com/sirwart/ripsecrets • Your editor’s Format on Save function • git-blame-ignore-revs 79
  34. #codereview Practices • All programmers review • Healthy con fl

    ict is OK, as long as it’s not personal • Talk about code, not people • "This design doesn't allow…" vs "You didn't consider" • Immediate fi x vs backlog • Create tickets or commit TODO/FIXME/XXX comments 81
  35. #codereview Other speakers with great Code Review material • Karl

    Wiegers • Jeff Atwood • Amy Gebhardt • Aaron Goldsmith • Adrienne Tacke 82
  36. 83