by DubiousPusher · 8y ago · 0 comments
1) Anything cosmetic gets a "nit" added to the comment.
2) When a review looks like mostly assets or boiler plate, I look through quickly for anything glaring and approve while noting my assumptions that the author has run the build and verified the additions.
3) If I'm in a hurry and the author is available I grab them and do an over the shoulder review. You might be surprised how much time this saves.
4) Don't struggle with difficult sections of other people's code unless you have a vested interest in remembering this specific section of code. Ask about unclear areas.
5) Trust your CI process. Don't try to consider every edge case for your reviewee.
6) Develop a culture of small work units. Encourage people to integrate every day or two. This means reviews are small and easier to grok.
Code reviews are not a guarantee of correctness. They are another tool. We should find a good trade off between effectiveness and cost to get the most value out of them not strive for perfection.
As for 1) I highly recommend to automate that away as much as possible. A strict syntax guideline and a toolchain that enforces it will go a long way.
Specifically, when doing something where the solution is well known for the beginning, creating PRs which are small and easy to understand is easy.
When instead I have to solve difficult problems for which I don't already know the solution beforehand, and which require writing quite a bit of complex code - eg multiple classes that work with each other, and which maybe work with some complex external system I/the team doesn't already know well - I find it difficult to split the PR into smaller chunks, because I "evolve" the separate classes together, while also doing exploratory testing.
"Production ready" code comes later in the process, and at that point I usually have quite a bit of code. I noticed that people don't like reviewing the non-production-ready code, but what's the alternative? In theory, after I found out what the solution is, I could go back and rewrite it better from the beginning, but that would just require too much time.
Didn't find a good answer yet.
1) Create "research prototype" of your solution. But do not commit it or commit it into separate branch (not master).
2) Create a plan how to split that code into smaller steps. Separate refactorings that will support your new feature - from your actual feature (that changes functionality).
3) Commit refactorings separately from your main feature commit. Keep every refactoring commit as small as possible).
4) At the end commit your functionality changing feature. If possible, split it into multiple commits too.
That should help with code review.
Remember, your team will have to code review your code multiple times:
1) When you are making your commits.
2) When your code reviewer reviews it.
3) In the future, when you or other team members maintain your code and try to understand why you created code that way.
So - optimize your commit to reduce code review time (even if it increases initial code writing time).
I'm now changing contract, hopefully with the new team it will be possible to find a better compromise. For example, I offered to walk the reviewer through my code, which I think would have helped a lot, but this was refused...
One concern here is you may ask questions whose answers are then given to you, and you alone. If it's likely someone else in the future will have the same questions, the "answers" should be in the form of improved code.
> 4) Don't struggle with difficult sections of other people's code unless you have a vested interest in remembering this specific section of code. Ask about unclear areas.
I'm not clear on the distinction between "difficult sections" and "unclear areas"? Either way, one of the outcomes of the review should be to make life easier for the folks that follow us.