@kannonboy's JavaOne 2016 presentation "Code reviews vs Pull requests"
Many styles and processes are available for code review. Which one is suitable for your team? Do you use Git, Subversion, or something more exotic? Do you prefer to review code precommit or via a pull request? Do you favor a feature branching, forking, or Gerrit-style workflow? This session breaks down the various popular options adopted by professional teams. It investigates pull requests (popularized by Bitbucket and GitHub), Gerrit’s specialized workflow, and other postcommit and precommit review systems, discussing the pros and cons of each. Finally, it shows the battle-hardened review processes used by Atlassian’s development teams, refined over tens of thousands of code reviews and pull requests and across countless retrospectives.
26. // flat fees and taxes
final float customsFee = 5.5f;
final float immigrationFee = 7f;
final float federalTransportTax = .025f;
public float calculateAirfare(float baseFare) {
float fare = baseFare;
fare += immigrationFee + customsFee;
fare *=
return fare;
}
AirfareCalculator.java
federalTransportTax;
@kannonboy
27. // flat fees and taxes
final float customsFee = 5.5f;
final float immigrationFee = 7f;
final float federalTransportTax = .025f;
public float calculateAirfare(float baseFare) {
float fare = baseFare;
fare += immigrationFee + customsFee;
fare *=
return fare;
}
(1 + )
AirfareCalculator.java
federalTransportTax ;
@kannonboy
28. Pre-commit review
From: Tim Pettersen <tim@atlassian.com>
Date: Mon, 12 Sep 2016 10:24:10 +1000
Subject: [PATCH] Calculate federal transport tax correctly
--- a/com/atlassian/airfare/AirfareCalculator.java
+++ b/com/atlassian/airfare/AirfareCalculator.java
@@ -10,7 +10,7 @@
public float calculateAirfare(float baseFare) {
float fare = baseFare;
fare += immigrationFee + customsFee;
- fare *= federalTransportTax;
+ fare *= (1 + federalTransportTax);
return fare;
}
$ git format-patch HEAD~1 --stdout
@kannonboy
29. Pre-commit review
dev
maintainer
public float calculateAirfare(float baseFare) {
float fare = baseFare;
fare += immigrationFee + customsFee;
- fare *= federalTransportTax;
+ fare *= (1 + federalTransportTax);
return fare;
}
Subject: [PATCH] Calculate federal transport tax correctly
@kannonboy
30. >
>
>
>
>
The braces are unnecessary.
Pre-commit review
dev
maintainer
public float calculateAirfare(float baseFare) {
float fare = baseFare;
fare += immigrationFee + customsFee;
- fare *= federalTransportTax;
+ fare *= (1 + federalTransportTax);
return fare;
}
Subject: Re: [PATCH] Calculate federal transport tax correctly
>
>
@kannonboy
31. >
>
>
>
>
>
>
> >
>
Technically true, but I think they add clarity.
>
>
>
>
>
>
>
The braces are unnecessary.
Pre-commit review
dev
maintainer
public float calculateAirfare(float baseFare) {
float fare = baseFare;
fare += immigrationFee + customsFee;
- fare *= federalTransportTax;
+ fare *= (1 + federalTransportTax);
return fare;
}
Subject: Re: Re: [PATCH] Calculate federal transport tax correctly
@kannonboy
35. Pre-commit review
Junio C Hamano*
Contributors
git@vger.kernel.org
* Also an oversimplification
@kannonboy
36. Pull requests
Post-commit review
Pre-commit review
master
for/master
Staging area
Pre-commit review
Version control agnostic
Difficult to read
High barrier to submit patches
Simple and decentralized
Difficult to iterate
Easy to keep ‘000s of people in the loop
Have to manually merge work
@kannonboy
44. Not an SCM
SCM host
(e.g. Bitbucket)
Review host
(e.g. Crucible)
Dev team
push & pull
code review
slurp
slurp
slurp
slurp
@kannonboy
45. Post-commit review
Post-commit review
Supports popular CVCS and DVCS
Have to manually merge work
Flexible review content
Need a separate VCS host
Easy to iterate
Hard to enforce process
@kannonboy
58. Pull requests
Post-commit review
Pre-commit review
master
for/master
Staging area
Staging area review
Sophisticated policy enforcement
Steep learning curve to use & administer
Iteration is a little awkward
FOSS project built in Java, on JGit
Git only
Clean commit history
@kannonboy
82. git merge --squash
@kannonboy
“Combine commits on branch into a new commit on master.
Fail if master has any commits that branch doesn’t.”
m
aster
--ff-only
83. git merge --squash
@kannonboy
“Combine commits on branch into a new commit on master.
Fail if master has any commits that branch doesn’t.”
m
aster
--ff-only
84. git merge --squash
@kannonboy
“Combine commits on branch into a new commit on master.
Fail if master has any commits that branch doesn’t.”
m
aster
--ff-only
85. Merge Commit Fast forward Squash
Concise history
Lose context of how
features evolved
Which should I use?
“Ugly” history
Full traceability
Hard to screw up
mostly some
--no-ff --ff-only --squash
@kannonboy
No merge commits
Verbose history
Requires rebasing
86. Pull requests
bit.ly/git-lfs
Sophisticated policy enforcement
Less flexible review content
DVCS had some limitations around file size
Choice of merge strategies
Multiple team members can author code under review
Git & Mercurial
@kannonboy
99. 4. Use blame to pick reviewers
$ npm install -g git-guilt
# find blame delta for current branch
$ git guilt `git merge-base master HEAD` HEAD
Alice Foo ++++++++++++++++++++++++(239)
Bob Bar ++++++++
Eve Baz -------
Mira Ted ----------------
Bec Opal ------------------------(-159)
@kannonboy
100. 4. Use blame to pick reviewers
bit.ly/suggest-reviewers @kannonboy
101. 4. Use blame to pick reviewers
bit.ly/suggest-reviewers @kannonboy
102. 4. Use blame to pick reviewers
bit.ly/suggest-reviewers @kannonboy
106. 8. Build a team policy, as a team…
…and enforce it! @kannonboy
107. 9. Add screenshots for UI/UX changes
(gifs / videos are even better) @kannonboy
108. 9. Add screenshots for UI/UX changes
(gifs / videos are even better) @kannonboy
Monosnap GIPHY ScreenFlow
109. @kannonboy
Ask a programmer to review 10
lines of code, they'll find 10 issues.
Ask them to do 500 lines and
they'll say it looks good.
@GIRAYOZIL
“
”
10. Keep it concise
110. 10. Keep it conciseSecondsperline
Lines of Code
1 line per second
100 lines per second
@kannonboy
source: bit.ly/review-stats
111. Code Review vs. Pull requests
Need to review multiple
repos at once
Not on Git
Heavily iterative workflow
Literally everyone else
Dendrophobia
+
@kannonboy
(Traditional)