reference:http://blog.codacy.com/top-10-faster-code-reviews/

This is a blog post of our Code Reading Wednesdays from Codacy (http://www.codacy.com): we make code reviews easier and automatic.

Follow the discussion on Reddit and Hacker News

How frequent is it for you to be reviewing code at 3am? 
When code reviewing, do you find yourself thinking: "I mentioned this before.. We should have some sort of process".

We're about to reach 2000 developers using Codacy and I've learned a ton from them along the way. 
A big aspect is how developers waste themselves in the process of code reviewing. 
Code reviews (pull requests, commit validation or approval), can be tedious and exhausting. 
I've gathered some aspects from people who are doing it right. 
These are small hints that I've seen from our users that highly help so you don't have to be alone at 5am reviewing your team's code.

1: Review less

Smaller commits lead to smaller more manageable code reviews. 
Besides other clear benefits (12345), dividing work into smaller chunks leads to more understanding of the intent of the change (hence more understanding into ways to put it better).

Problem: My team likes to have big bulky commits.

Solution: Start dividing your work into smaller commits. When your team sees the clear benefits on reviewing your code, they will most likely follow.

2: Time boxing

Code reviewing tends to be secundary in the process. Hence, it's common to see it slipping away through the day when finally you're all alone in the office validating work from other people.

A good way to help mitigate this is by assigning a time slot in the day to review code. 
When that is not possible, try to apply a maximum value to it (like 60,70,80 minutes).

Problem: My team ships code into production at crazy hours.

Solution: Prioritize your reviews by checking the essential when a complete review is not possible (see the review check list below). When you see yourself not being able to properly review code, try to change timing, deploy hours.

3: Distribute/Delegate

Make sure reviews don't fall on the same person. 
I've seen companies centralising code reviews on one person. 
It makes for:

  1. Overworked people
  2. Slower deploy times
  3. Bad reviews (reduced attention span)

Problem: But my CTO is micromanaging the code reviews to make sure everything is alright

Problem2: But I don't trust my team to deploy code without my eyes on it.

Solution: Teach a man to fish. Also make for your (or your boss) review as an additional safe guard but not a essential blocking one.

4: Shared Code guidelines

Before enforcing a best practice, one can always make sure everyone is on board with it. 
Take time to view what guidelines are important. 
Always hear when developers want to add to the guidelines. 
Good people always look for ways to improve their craft. Good developers always want to stay updated.

For different programming languages, you have different coding guidelines.

If you don't yet have a coding guideline, here's a list of them by programming language to start the conversation :

Taking community driven standards (or at least basing your company's code style in it) it's a great idea since it ease's new developer on boarding and better community help.

5: Create a checklist upon review

Having a checklist to review code greatly improves the efficiency of the process. 
Sometimes in the middle of a review we identify an issue and we remember we haven't been really paying attention to that specific problem previously (which then leaves you with the uncertainty of an incomplete job).

Ideally, one should have every important aspect in one's head (since for N lines of code, checking each one for N code rules is O(N2) - absurd of course but you get the point).

Also, the inverse of having coding guidelines (point 4) is enforcing them.

Problem: There are a lot of engineering issues that don't fit into the checklist.

Solution: Definitely right. These can be addressed afterwards in a team/one-to-one short meeting. Overall, this is a learning process and is much more important to start doing some early and learn from what is missing or being left out.

Here's a small suggestion from me of a code review checklist to start the conversation in your team:

  1. Is the code style according to our own?
  2. Is this code according to the best practices we/community defined?
  3. is this code problematic/inefficient/error prone/not clear/previously proved bad/not compatible with architecture
  4. DRY/SRP/KISS/YAGNI/Smell

Here are other checklists you might find interesting as well: 123456

6: Use collaborative review tools

Doing Git (or repository based) reviews only (by looking at logs, diffs and commits) is time consuming. 
One should look for a tool that allows you to:

  1. quickly review what changed
  2. quickly be able to communicate with people
  3. decide to approve (or not) the commit

By concentrating these three aspects into one tool, you can be more efficient at the underlying actions we need to execute a code review.

If you're choosing a tool, choose one that you can get your whole team on board. 
Github and Bitbucket both have pull requests which represent a workflow with built in code reviews.

Going forward, you have brilliant tools from the smart guys from SmartBear and also Crucible from Atlassian

7: Do a little, even if no time

Problem: It's Thursday and you want to deploy some features into production (because you don't deploy code on Fridays). However, it's been a specially tough week and so you haven't really been paying attention to how code evolved. 
Before you know it you have 200 commits to review.

Solution: Prioritize your checks and don't strain yourself. Only check for major issues. Code style can be checked later or automatically through linting afterwards.

Knowing the history of the project (and the problems you've had), you also have a sense to the more important aspects to look for.

The important part is sharing ownership and sharing knowledge.

8: Use short circuiting

When time is of the essence and reviewing every line written is not an option, take an incremental approach.

When you've found a possible buffer overflow or a function call you know it will blow up in production, it shouldn't really matter to review code style.

In your code review checks, you can insert short circuiting elements: if a commit has a big enough problem that needs to have further development, one can ignore smaller less important problems for a future review of that code when it is corrected.

9: Helpful commits

Concise and to the point commit messages with code that is commented really narrows the focus of the review. 
The code reviewer will have a much easier job if you talk about the implemented feature and the design decisions behind it. 
Helping your team members is a good way for them to see how valuable a proper commit is. 
Take a look at how the Linux kernel guides their own submission:https://www.kernel.org/doc/Documentation/SubmittingPatches.

10: Automate with Codacy

A final and great way to reduce the time it takes to review code is by reducing the number of aspects of your checklist that you need to pay attention to.

Codacy is a tool we built to automate some aspects of your code reviews. Codacy checks for code style, best practices and common errors. This frees you to only check for what matters. 
Furthermore, you can always refer back to Codacy whenever you find an issue.

Automation lets you be better and save time. Combined with the aspects on top, you're on your way to make sure you don't spend more time than you have to doing code reviews.

Because you care and because you always want to be better, automation is a great way to optimize your review workflow process.

Conclusion

I've passed through the experience of our users when reviewing code for their companies. 
Overall, this practice will always lead to better code, shared knowledge and bigger consensus. However, improving the process is something we can greatly benefit from.

10 ways to be a faster code reviewer--reference的更多相关文章

  1. 10 Ways to Inspire Your Team

    Inspire. Just the word itself causes us to pause and think. We may remember our own personal heroes ...

  2. TED #03# 10 ways to have a better conversation

    Teach you how to talk and how to listen Many of you have already heard a lot of advice on this, thin ...

  3. Jupiter Code Review Reference -- Jupiter代码审查工具使用参考

    Jupiter Code Review Reference -- Jupiter代码审查工具使用参考 (修改版) 原创 2010年07月06日 10:43:00 标签: 审查 / reference  ...

  4. windows 10环境下 使用 msys2 + vs code 配置 c++ 的编译环境

    不太多描述 msys2 与  vs code  ,既然你需要安装 一种语言的编译环境了 ,你肯定对这两个不陌生: 1. 先安装msys2; (下载多少位的msys2就安装多少位的 mingw,本人安装 ...

  5. Cheatsheet: 2014 03.01 ~ 03.31

    .NET Should I be concerned about PDB files? async and await -Simplified-Internals Web Performance tr ...

  6. Code optimization and organization in Javascript / jQuery

    This article is a combined effort of Innofied Javascript developers Puja Deora and Subhajit Ghosh) W ...

  7. Peer Code Reviews Made Easy with Eclipse Plug-In

    欢迎关注我的社交账号: 博客园地址: http://www.cnblogs.com/jiangxinnju/p/4781259.html GitHub地址: https://github.com/ji ...

  8. 17款code review工具

    本文是码农网原创翻译,转载请看清文末的转载要求,谢谢合作! 好的代码审查器可以大大地帮助程序员提高代码质量,减少错误几率. 虽然现在市场上有许多可用的代码审查工具,但如何挑选也是一个艰巨的任务.在咨询 ...

  9. Tool:Visual Studio Code

    ylbtech-Tool:Visual Studio Code Microsoft在2015年4月30日Build 开发者大会上正式宣布了 Visual Studio Code 项目:一个运行于 Ma ...

随机推荐

  1. ets dets

    相同点:ets和dets都提供“键—值”搜索表 不同点:ets驻留在内存,dets驻留在磁盘 特点:ets表和dets表可以被多个进程共享,因此通过这两个模块可以实现数据间的交换 一  ets表 实现 ...

  2. Web 检测代码 web analysis 开源 open source

    1. Grape Web Statistics Grape Web Statistics is a fairly simple piece of analytics software. Grape i ...

  3. permission denied部署django 遇到没有python_egg_cache的问题解决

    检查/etc/httpd/logs/error_log,看是否有如下错误: [Errno 13] Permission denied: '/var/www/.python-eggs' 这时候需要编辑“ ...

  4. 什么是ADB

    ADB, Android Debug Bridge, 是一个client-server程序,可以用来和安卓设备交流 Client: 用来发送命令的,client运行在开发机器上(电脑cmd, adb ...

  5. Android问题-DelphiXE5开发Andriod连接Webservice乱码问题

    问题现象:在使用DelphiXE5开发Andriod连接Webservice乱码. 问题原因:数据类型不同. 问题处理:为了不让广大朋友再烦恼,我就把解决办法写出来吧,把数据库中我们要查询的字段类型改 ...

  6. Maven Archetype Plugin

    使用Archetype的一般步骤 命令——mvn archetype:generate 输入命令后,Archetype插件会输出一个Archetype列表供用户选择:选择自己想要使用的Archetyp ...

  7. datatable把一个LIst的数据放入两个colum防止窜行的做法

    DataColumn objectOne = new DataColumn("objectOne", typeof(object)); dt.Columns.Add(objectO ...

  8. POJ1338Ugly Numbers(DP)

    http://poj.org/problem?id=1338 第一反应就是DP,DP[i] = min{2*DP[j], 3*DP[k], 5*DP[p] j,k,p<i};于是枚举一下0-i- ...

  9. setsockopt的作用列表

    功能描述: 获取或者设置与某个套接字关联的选 项.选项可能存在于多层协议中,它们总会出现在最上面的套接字层.当操作套接字选项时,选项位于的层和选项的名称必须给出.为了操作套接字层的选项,应该 将层的值 ...

  10. 设置UIButton文字大小颜色不同

    _loginBtn = [[UIButton alloc]initWithFrame:CGRectMake(iconX, CGRectGetMaxY(passwordBGView.frame)+25, ...