News for hackers. Stuff that matters.
Re:Moving Fast with High Code Quality by omouse on Monday July 27, 2015 @06:32PM (#9958436)
This is the part that I don't understand,

>Even if each round of review takes 2 days and there are 2-3 such iterations, it is easy for the author to stay blocked for good part of a week leading to wasted time.

How can the author of the code be blocked while waiting for a code review? Can't they use that time to review someone else's code or to work on something else in a separate branch or, heaven forbid, learn or train themselves?

I mean we never seem to find time to train developers but the time between writing code and having it pass review could be used for education not just sitting around and waiting.

>For code reviews to work well, each change should be reviewed by the people who have enough context on that change. It's even better if these code reviewers are responsible for “maintaining” the code they are reviewing so that they are incentivized to make the right long-term trade-offs

This makes sense at first but don't you also want more people looking at the code who don't have complete context so that the context must be explained to them and then they can learn more about the code base? Isn't reducing the bus factor also a priority?

Re:Moving Fast with High Code Quality by chadaustin on Monday July 27, 2015 @07:34PM (#9958685)
The problem is not that the time waiting on a code review can't be used in some other way. It's that the constant interruptions seriously hurt straight-line productivity. "OK, done with this minor patch. Now, uhhh, while I wait for code review, I guess I'll go review this other thing... And then start a new patch.... Code review is done now? Better context-switch back."

I'm not strictly opposed to pre-commit reviews, but I think it's incorrect to be dismissive of their cost.

Re:Moving Fast with High Code Quality by mkozlows on Monday July 27, 2015 @07:51PM (#9958752)
I agree with this to some extent, but it can be ameliorated a lot with smaller and more frequent PRs. If your PR is enormous and represents a week's worth of work and you end up having to respond to 20 comments, it's going to be awful. If your PR is small and represents hours' worth of work and you have to respond to 1-2 comments, it's a lot less obnoxious. (And you'll have more natural opportunities for context-switching, so responding to comments won't be so distracting.)
Re:Moving Fast with High Code Quality by deepGem on Tuesday July 28, 2015 @02:54AM (#9959903)
I can't agree more to this approach. Smaller changes are easy to review and manaage. We developers need a push to make this happen though.
Re:Moving Fast with High Code Quality by MaulingMonkey on Tuesday July 28, 2015 @04:34AM (#9960231)
This also needs proper VCS support - by which I mean DVCSes that let you pile commits up to the same files one after another sanely, or reviews after commit rather than before (better have a good branching setup!)

My last job was perforce (no unsubmitted commit stacking) with everyone developing directly against a single branch. In theory, code reviews were supposed to happen before hand.

In practice, I submitted small changes from the hip, and complained when my coworkers gave me a week long spitball of unrelated features in a single mega-commit. Not that I wasn't guilty of that myself. Bleh.

Re:Moving Fast with High Code Quality by yummyfajitas on Tuesday July 28, 2015 @07:44AM (#9960757)
This works in relatively shallow codebases (e.g. most python/django webapps). In a codebase with deeper dependencies, not so much.

    - def f(x: X): Option[X]
    + def f(x: X): MyErrorType \/ X
This is not a small change, most users of f now need to be changed as well.
Re:Moving Fast with High Code Quality by couchand on Tuesday July 28, 2015 @08:14AM (#9960878)
Right, but if that's the only change made, reviewing find-and-replace is trivial. The diff might bleed a bit on the pattern matching, but as long as you restrict the commit to the single logical change, verification is still pretty easy.
Re:Moving Fast with High Code Quality by yummyfajitas on Tuesday July 28, 2015 @08:59AM (#9961100)
The entire point of such a commit is to not be just a search and replace, but instead to have different behavior depending on the value of the error type. E.g. crash on network error, UPDATE rather than INSERT on specific SQL error.

Some changes simply cannot be broken into tiny atomic pieces. Often these are important changes for long term maintainability.

Re:Moving Fast with High Code Quality by couchand on Tuesday July 28, 2015 @09:05AM (#9961140)
Here's my experience with this sort of change: You have exactly one usage where you NEED the update. After deciding to make it you've identified a few other places where you can use the updated code.

The Right Way (TM) to make that change, then, is to make only the change to the result type in the first commit (along with the pattern matching necessary to ignore it), followed by a commit for each place that the updated result type can be usefully used.

Change the code without changing the behavior: i.e. REFACTORING. Run the tests, verify you didn't break anything, then start writing tests for the behavior you wish to change, followed by changing that behavior.

If you think you're at atoms you probably haven't seen strings.

Re:Moving Fast with High Code Quality by yummyfajitas on Tuesday July 28, 2015 @09:35AM (#9961321)
I suppose it could be done that way. But that seems like a lot of extra work, and you also lose the compilers help. Also, in my experience changes like this actually do involve lots of subtly broken code - think about it, anyone using fold on a network error is making a mistake (retrying the use of a closed connection).

If you fix the behavior everyplace the compiler complains, you are guaranteed to resolve most issues (ignoring overloaded methods, e.g. getOrElse). If you use a toOption method on the union type to make a tiny atomic change, the compiler will no longer complain in all the places that mistakes are being made.

I suppose an intermediate way might be to rename f to f_DEPRECATED, replace everywhere, and build the new method returning the right type. But in my experience its better just to bite the bullet and change everything.

Re:Moving Fast with High Code Quality by specialk on Monday July 27, 2015 @07:57PM (#9958770)
My team added something four weeks ago that might be an idea to try - we're still trailing it ourselves. It started accidentally and became a tradition on our team though so your mileage may vary.

If the pull request is small, fixes a bug or is a blocking you, then you can spend you quick-code-review-chip for the week and ask the team to look at it at their first available opportunity. (Sometimes reviewed within 15 minutes, usually an hour tops)

It allows team members to ask the rest of the team to unblock them quickly. Limiting it to one a week prevents abuse of their team mates' time and encourages all team members to plan their work out ahead as to reduce blocking.

We also wrote a quick HipChat bot that keeps track of who's spent their quick-review-chip too.

Re:Moving Fast with High Code Quality by obstinate on Monday July 27, 2015 @09:23PM (#9959008)
My team handles this by committing to personal dev branches, then reviewing relatively small merges to mainline. If a review is in progress and you want to work on changes that depend on the code in review, you make another dev branch from the review commit. Then you merge any changes back in after the review is done.

Ordinarily this final merge is fairly painless, since you ideally won't have many code reviews that call for sweeping changes in your design. If you do, that's a sign of failure earlier in the process.

Re:Moving Fast with High Code Quality by specialk on Monday July 27, 2015 @07:49PM (#9958746)
I completely agree that how can you get blocked waiting for a code review? Some concurrency is wonderful for avoiding being blocked.

In work I currently have 3 pull requests open all touching different sections of the product. The 3 PRs are all at different stages of the review process. For example, I'll be closing one first thing tomorrow and deploying it out (don't like deploying in the evenings - its bad luck). Another I just opened as I left work today, so I doubt anyone's reviewed it yet.

I'm sure Quora has a big enough codebase and not enough developers (like most companies) that they always have a list of things a mile long that they would like to do or should do, be that new features or just refactoring.

2-3 days isn't long for a review and iteration cycle in itself. I have one PR that is currently open for 5 working days at this stage. We decided that it didn't quite fit the bill on the first draft . It is blocking progress on two other tasks in our backlog but we also have 14 things on our backlog of goals for this week. The team is working around it while we finish it off or create issues for things we think have fallen outside the scope of the initial job.

One thing we've noticed alot on my team is that we try and make our pull requests for review as small as possible. We all have a rough guide of about max 500 lines. Sometimes we do go over but its a rough guideline. Smaller PRs are just easier to review for everyone involved. Reviewers don't have walls of code to break through or need to keep tons of context in their head.

Post-commit reviews (or post-merge into master or whatever you process is) is an interesting idea. I'd be curious to see what my team think of the idea tomorrow for a small sub set of our codebase.

Re:Moving Fast with High Code Quality by awinder on Monday July 27, 2015 @07:05PM (#9958575)
I love this comment. I've heard this actually voiced by developers having trouble coping with code reviews -- "I'm blocked, I can't work on anything else". Think you're right on with the idea of using it for training / research / pet project time.
Re:Moving Fast with High Code Quality by omouse on Monday July 27, 2015 @08:34PM (#9958892)
I've actually gotten into trouble because I spent more than 5 minutes doing a code review of a pull request. I had to code review for 3 junior devs and one senior; the junior devs all knew little Python so only I could review their code while the other senior dev was busy. It took hours to wade through and double-check their code. I always suggested to them to look up some Python libraries or to work on puzzles to practice or to review the code as well or talk to each other about the next piece of work. There's so many other things to do than to keep coding.
Re:Moving Fast with High Code Quality by gknoy on Tuesday July 28, 2015 @01:58AM (#9959752)
That sounds less like "code review", and more like "Mentoring". If you find a way to position it that way, you can bring that up with your boss(es) before your next performance review.

I've found mentoring other developers (whether it's explaining "Here's the facets of how we test All The Things", or "Here's how git branching works") to be profoundly fulfilling. I love explaining things. The best part is, fostering the idea of teaching each other means that others can mentor YOU as well on things, and you (and they) don't need to feel threatened.

Re:Moving Fast with High Code Quality by superuser2 on Monday July 27, 2015 @08:38PM (#9958901)
>Can't they use that time to review someone else's code or to work on something else in a separate branch or, heaven forbid, learn or train themselves?

Yes, but context-switches are expensive, particularly when you have several reviews in progress across several projects.