Wagner Lab, Stanford
2014 October 2
Kurt MacDonald
Design Director, Maginatics
We do this stuff because of who we are.
We follow these steps because they are the agreed upon workflow for our organization.
Btw, the commit message rules we use in the kernel really *are* objectively better. The fact that some other projects don't care that much is fine. But just compare kernel message logs to other projects, and I think you'll find that no, it's not just "my opinion". We do have standards, and the standards are there to make for better logs.
“Merge branch 'asdfasjkfdlas/alkdjf' into sdkjfls-final”
Capitalized, short (50 chars or less) summary
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.
Write your commit message in the present tense: "Fix bug" and not "Fixed
bug." This convention matches up with commit messages generated by
commands like git merge and git revert.
- Bullet points are okay, too
- Typically a hyphen or asterisk is used for the bullet, preceded by a
single space, with blank lines in between, but conventions vary here
- Use a hanging indent
All code that goes into the product must go through code review.
There are still bugs.
There are still style clashes.
There is still miscommunication.
→ Test coverage.
→ Maintain a style guide.
→ Make things simple and clear.
A patch must pass the verifier before it can be merged. Jenkins, our CI server, automatically runs the test scripts for each project when a new patch set is pushed.
Looks good to me, approved
Looks good to me, but someone else must approve
No score
I would prefer that you did not submit this
Do not submit
+2
+1
0
-1
-2
Does it adhere to the house style?
Does it work?
Following the below guidelines to improve review quality and speed up the process:
Try to keep review requests small.
This makes the history clear and it can dramatically speed up response times from reviewers.
Try to split independent changes into different requests.
Changes that are logically separate should be split into separate commits.
Give feedback on reviewers’ comments
This could be as simple as a “Done” comment. This saves time for the reviewers in followup.
Constructive feedback is always welcome.
The goal is to improve the quality of our code.
1.
2.
3.
4.
“If there is too much overhead/frustration, then you will not do it.”
“No shame in bad code, shame in not fixing it (or publishing bad code).”
“All about people: easy to be passive aggressive. Sometimes better to talk directly.”
“Pick a ‘decider of all things that don’t matter’ to prevent bike-shedding.”
“Writing good commit messages helps people know if they even need to look at the code.”
How many people review a given piece of code?
To what extent is the code actually reviewed? i.e., do you simply read it, or do you actually test it by pushing data through?
At what point in the code writing process is the code reviewed? i.e., every time a minor change is made vs. major change vs. when an entirely new script is written?
How do you make the process fair so that people dedicate approximately equal amounts of time to code review?
We assume you use GitHub or something similar for accessing code?
Less formal code review.
Track bugs and features.
Sharing snippets of code.
Existing code? What to do?
cd /project
git init
git add .
git commit -m "Put project in git"
git remote add origin <remote repository URL>
git push origin master
One of the things I’ve been pushing is code reading. I think that is the most useful thing that a community of programmers can do for each other—spend time on a regular basis reading each other’s code.
Crockford: At each meeting, someone’s responsible for reading their code, and they’ll walk us through everything, and the rest of us will observe. It’s a really good chance for the rest of the team to understand how their stuff is going to have to fit with that stuff.
We get everybody around the table; everybody gets a stack of paper. We also blow it up on the screen. And we all read through it together. And we’re all commenting on the code as we go along. People say, “I don’t understand this comment,” or, “This comment doesn’t seem to describe the code.” That kind of stuff can be so valuable because as a programmer you stop reading your own comments and you’re not aware that you’re misdirecting the reader.
Having the people you work with helping to keep your code clean is a huge service—you find defects that you never would’ve found on your own.
I think an hour of code reading is worth two weeks of QA. It’s just a really effective way of removing errors. If you have someone who is strong reading, then the novices around them are going to learn a lot that they wouldn’t be learning otherwise, and if you have a novice reading, he’s going to get a lot of really good advice.
And it shouldn’t be something that we save for the end.
I welcome your questions, comments, and feedback.
# Create a new branch for development.
$ git checkout -b newFeatureBranch
# Write some code.
$ git status
$ git add -p
$ git commit -m "Add foo
>
> Fixes #1138.
>
> Some additional details after one blank
> line that describe the changes."
$ git push origin HEAD:refs/for/master
# Make changes based on feedback.
$ git add -p
$ git commit --amend
$ git push origin HEAD:refs/for/master
# Make more changes based on comments.
$ git add -p
$ git commit --amend -C HEAD
$ git push origin HEAD:refs/for/master
# Move back to the master branch.
$ git checkout master
$ git fetch
$ git merge origin/master
$ git log
# Repeat.* Very short
* All people working on related pieces are present
* Discuss requirements and design
* Discuss and agree on interface: data and api
* Agreement before going away to code…
* Come back together as often as necessary
Inline documentation
Tools: YUIDoc
README.markdown
Use cases:
* describe in plain language the expected function of a program
* list steps for “happy path”
* errors conditions handled along the way
* screenshots for visual inspection and stuff that can’t be tested