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

Code Reviews are Teachable Moments

Code Reviews are Teachable Moments

This will not be a discussion about the process of reviewing code, but a deeper dive into how we can leverage the code review process to teach each other.

What we'll cover:

- What are teachable moments?
- Can we identify them in a Pull Request?
- Can we capitalize on these moments?
- Can we get developers to provide better insights in reviews?
- What should we do as [junior/senior] developers [giving/receiving] reviews?

Eric Allen

July 26, 2018
Tweet

More Decks by Eric Allen

Other Decks in Technology

Transcript

  1. Opinion: “Senior” developers who do not or cannot teach via

    Code Reviews are not really “Senior” developers.
  2. What is a Teachable Moment? An unplanned opportunity to offer

    insight that sidetracks the discussion to something that has captured attention. It cannot be planned for and must be seized.
  3. Why are Teachable Moments important? A Teachable Moment provides a

    rare instance where a “student” is uniquely positioned to receive the maximum impact from your teaching.
  4. Can we identify Teachable Moments? • Is the developer doing

    something novel? • Is this a brand new feature? • Did they use a convention that doesn’t align with the rest of the codebase? • Is this clearly their first time approaching this kind of problem? • Is this their first Pull Request?
  5. Can we identify Teachable Moments? • Did they leave comments

    with red flags? • “..hack…” • // FIXME: • // TODO: • “…can be removed later” • “…but it works”
  6. Can we identify Teachable Moments? • Are they reinventing the

    wheel? • Is there already a method for this? • Is there a native API for it? • Are there already other dependencies that can handle this?
  7. Can we identify Teachable Moments? • Is it new? •

    Is it scary? • Is it redundant?
  8. How can we capitalize on a Teachable Moment? • Socratic

    Method • Ask them “Why?” • Ask them how they think we should approach some problem • Ask them to explain how they implemented some solution
  9. How can we capitalize on a Teachable Moment? • Provide

    links to further research • Find Medium posts that further explain details • Find JSPerf results that illustrate your point • Find Stack Overflow answers with details descriptions
  10. How can we capitalize on a Teachable Moment? • Don’t

    just show, but tell • A blob of code isn’t helpful and doesn’t tell the “student” anything • “Do this instead,” won’t help the “student” learn why and internalize it • Providing detailed notes will invite the “student” to discuss the review
  11. How can we capitalize on a Teachable Moment? • Always

    build trust • Teachable Moments are more frequent and more effective if the “student” trusts the “teacher” • Find ways to build trust outside of code reviews • Build confidence and camaraderie (coffee, pairing, etc.)
  12. How can we capitalize on a Teachable Moment? • Relate

    to your journey • don’t forget where you came from and the things you learned along the way • refer to the way you learned something when explaining it • let your “student” see behind the curtain; it humanizes you and builds trust
  13. How can we capitalize on a Teachable Moment? • Ask

    questions • Provide reference material • Tell them why • Build trust • Share your experience
  14. How not to capitalize on a Teachable Moment: Warning: Harsh

    language ahead; you may want to avert your gaze.
  15. How not to capitalize on a Teachable Moment: • Be

    a Linus Torvalds: • “The above code is shit, and it generates shit code. It looks bad, and there's no reason for it.” • “How the hell did this get to the point where crap like this is even sent to me? Nobody tested anything?”
  16. How not to capitalize on a Teachable Moment: • Leave

    a cryptic review • use emojis: • use single word responses like “No,” “Wrong,” “Unsubscribe,” etc. • use heavy sarcasm • use an odd format like a poem, haiku, meme, etc.
  17. How not to capitalize on a Teachable Moment: • Be

    dismissive: • don’t answer “student” questions • use words like “obviously,” “clearly,” etc. • there is a big difference between: • “Can you tell me why you did this?” • “Why would you do this?”
  18. How not to capitalize on a Teachable Moment: • Just

    post code without any context • Do this: [insert block of code here] • Should be [insert variable/method name here] • [insert completely rewritten method here without any context] • [insert link to MDN page for some JS method here]
  19. How not to capitalize on a Teachable Moment: • Be

    a jerk • Be cryptic • Be dismissive • Don’t provide context
  20. Can we create a Teachable Moment when asking for a

    Code Review? • Review your own Pull Request • explain how you ended up at this approach • ask if there is already a codebase convention for this situation • mention how you may refactor some particularly dense bit of code
  21. Can we create a Teachable Moment when asking for a

    Code Review? • Leverage Cunningham’s Law: • “The best way to get the right answer on the Internet is not to ask a question; it’s to post the wrong answer.” • just put up a Pull Request; it doesn’t have to be pretty or right • refactor something dense and important and put up a Pull Request
  22. Can we create a Teachable Moment when asking for a

    Code Review? • Leave breadcrumbs: • // TODO: • // FIXME: • // HELP! • // HACK: • // I have no idea why this works
  23. Can we create a Teachable Moment when asking for a

    Code Review? • When all else fails: be argumentative. • “Why should we do it that way?” • “What’s the point of that?” • “Can you explain what you’re asking for here?” • “That doesn’t seem like the best approach.”
  24. Can we create a Teachable Moment when asking for a

    Code Review? • Review yourself • Be wrong • Fire a flare • Debate
  25. Opinion: Leveraging the Teachable Moments of Code Reviews is an

    important trait of a Senior Developer and one of the best ways to help teams grow.