Code Reviews

What is the purpose?

  • Build a better product.
  • Build a better team.

Build a better product?

  • High-Quality Code.
  • Well tested.
  • Code is read 100x more times than it is written.

Intiutive

Build a better team?

  • Less obvious but equally or even more important.
  • Share knowledge across people.
  • Build better connections between team members.
  • Respecting each other's "opinions".
  • Learning how to be "Objective".

Not so clear...????

Parties Involved

  • Author of Pull Request
  • Reviewer of Pull Request

For the author?

  • How to prepare their code for review?
  • How to deal with negative emotions after code review?

Preparing for Code Review

Why should you care?

Β 

  • A good pull request will be reviewed quickly;
  • It reduces bug introduction into codebase;
  • It speeds up the code review process and, consequently the product development.

Preparing for Code Review

  • Have descriptive commit messages.
  • Make sure you have all prepare commit and pre-commit hooks installed & working.

Good commit messages

Preparing for Code Review

  • Note down your mistakes and learn from them.
  • To do ^ effectively, try to think "What would you do differently next time onwards" as Einstein says "Stupidity is doing the same thing over and over again and expecting different results".
  • Be devil's advocate 😈
  • Get in the mind of the code reviewer.

Self Review

Preparing for Code Review

Make sure all CI builds are passed and working, failing CI builds === No CI Builds.

CI Builds

Preparing for Code Review

Document complex part OR some decision which you think

Document Your Code

Dealing with negative emotions

It is OK to make mistakes, we all do.

  • The only real mistake is the one from which we learned nothing - Henry Ford.
  • Look at PRs of people you think are "pros" πŸ€—
  • Don't repeat mistakes.

Dealing with negative emotions

Assume good intentions

  • Be vary of "Fundamental Attribution Error".
  • Argue the steel man vs straw man.

Dealing with negative emotions

Watch "Myth of genius Programmer"

For the reviewer...

For the reviewer...

Add πŸ’•

"Rename this", "Move this to models" etc.

V/S

Β "Please rename this", "I think we should move this to models, let me know what you think?/Please move this to Models".

For the reviewer...

Add πŸ’•

The practice spreads. I see 2 people commenting like that, we think it is okay to do this, and soon we are just a bunch of people shouting at each other in PR comments πŸ˜ƒ

For the reviewer...

Add πŸ’•

Forces the other person to think and be involved in process vs taking orders.

For the reviewer...

Add πŸ’•

Also, if you can be anything in this world - Be KindΒ  & considerate β™₯️.

For the reviewer...

Be objective πŸ”₯

There are always some subjective things that you "feel", and then there are objective things that you "know" and have evidence for.

Push for objective things and learn to let go for subjective things.

For the reviewer...

Get on with pair programming

For the reviewer...

Learn to let go...

  • YAGNI
  • Reversible & irreversible decisions
Made with Slides.com