编程小贴士

给你的编程提供小点子


为什么每个团队都需要 Code Review?

不少开发团队和创业公司都在纠结是否要执行 code review,既希望改进代码质量,又担心带来的负担会拖慢项目进度。实时上,在软件开发中质量和效率往往并不是二选其一的关系。能产出高质量代码的团队通常效率也非常高。

在我作为工程师的职业经历中,自动化测试和 code review 可说是能同时提高代码质量和开发效率的两个最有效的手段。所谓 code review,和学术界的 peer review 类似。Peer review 是由同事或同行对一位作者的作品进行查阅并提出建议和问题,只有当所有提出的问题都得到满意的答案后,作品才能发表。对于 code review 来说,作品就是代码,发表就是把代码 commit 到官方代码库。

在 Code Complete 这本书中讲述了两个很有说服力的案例。在一项对同一个团队开发的很多个程序进行对比的研究中,没有经过 review 的程序平均每 100 行有 4.5 个错误,而经过 review 的程序平均每 100 行只有 0.82 个错误,也就是说 80% 的错误在 review 中被修正了。AT & T 的一个 200 多人的部门在开始执行 code review 后,开发效率提高了 14%,而错误减少了 90% 左右。

除了减少缺陷,避免在诊断错误上浪费时间,review 的过程还可以通过相互的督促保证代码有好的可读性、文档、风格,并同时检查测试覆盖率等开发过程中的规范,从而提高团队的协作效率。对于所有复杂的事情来说,总是越早发现问题,解决问题的成本越低。

对于经验不足或者刚开始一份新工作的人来说,通过 code review 可以得到更资深的人帮助,更快熟悉现有的规范和架构,在新的环境和团队中快速提升。

对于资深的工程师来说,让其他同事 review 代码,有利于在团队中传播经验、知识和好的实践。身边的同事水平提高会让自己的工作也更高效。并且谁都有需要休假的时候,无论是公司还是个人都不希望有太 多工作因此而停滞,如果有平时就熟悉自己工作的同事,这个问题就很好解决。

像很多其他事情一样,code review 最难的就是迈出第一步。一旦开始,花在 review 过程的每一分钟都会很快被成倍地赚回来。如果你不在一个可以一下改变团队流程的位置上,那么至少可以和认同这件事的少数同事先开始实践,当价值开始体现的 时候,相信其他人会乐于效仿。

20 Responses to “ 为什么每个团队都需要 Code Review? ”

  1. i love pron说道:

    F2UfzY you make running a blog look easy. The total look of your site is great, as well as the

  2. watch movies说道:

    Look forward to checking out your web page for a second time.

  3. animal drawings说道:

    There as certainly a lot to know about this topic. I really like all of the points you have made.

  4. It is best to participate in a contest for among the finest blogs on the web. I all recommend this web site!

  5. Click to read说道:

    Very good post. I certainly appreciate this website. Keep writing!

  6. look forward to seeking more of your great post. Also, I ave shared your site in my social networks!

  7. to learn more说道:

    It as hard to come by well-informed people in this particular topic, however, you seem like you know what you are talking about! Thanks

  8. click here说道:

    I’а†ve recently started a site, the information you provide on this web site has helped me greatly. Thank you for all of your time & work.

  9. Thanks a lot for the post.Much thanks again. Much obliged.

  10. microblog说道:

    I think this is a real great article post. Much obliged.

  11. You made some decent points there. I looked on the internet for the topic and found most individuals will agree with your website.

  12. Rattling superb info can be found on blog.

  13. Green Card说道:

    Major thanks for the blog post.Really thank you! Awesome.

  14. Nwokolo说道:

    You have mentioned very interesting points ! ps decent website. I am going to a special place when I die, but I want to make sure my life is special while I am here. by Payne Stewart.

  15. klm coupon code说道:

    Thanks for sharing, this is a fantastic blog article.Really looking forward to read more. Cool.

  16. Muchos Gracias for your blog article. Want more.

  17. Thanks a lot for the article post.Really looking forward to read more. Cool.

  18. Wow, marvelous blog layout! How long have you been

  19. I was suggested this web site by way of my cousin. I am now not sure whether this post is written via him as no one else recognise such certain about my trouble. You are amazing! Thank you!|

  20. Some really superb info , Sword lily I found this.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>