>_ SEEDOFWHALE / INDEX

技术笔记目录

按主题找文章。点标题看正文,技术索引可直达原文或视频。

[译] 代码评审先看正确性,再看代码风格

授权转载与 AI 辅助翻译(非官方)
原作者及版权:© Gunnar Morling;首发:2022-03-10
英文原文:The Code Review Pyramid
授权:英文原文及本简体中文译文均按 CC BY-SA 4.0 分享。编辑改动:增加中文翻译、译注和分类导航;保留完整英文正文,调整排版,外嵌演示以链接呈现。未暗示原作者认可本译文。

分类:基础与工程作品 · 代码评审、自动化
博客首页目录 · 一手技术资料总索引

中文译文

做代码评审时,很常见的一幕是大家对格式和写法讨论很久,而该多花时间的问题反而没人仔细看:这次改动是否做到了该做的事?性能如何?对现有客户端是否向后兼容?诸如此类。

为了提醒大家注意这个问题,也为了说明评审时该看哪些方面,我前几天在 Twitter 上发了一张小图,叫作“代码评审金字塔”。它想把注意力拉回到评审最重要的部分(至少在我看来如此),也标出了哪些环节能够、也应该交给自动化。

有人问起便于长期引用的位置,也有人想要能打印的高清版本,所以我把图放在这里:

代码评审金字塔,Gunnar Morling

也可以下载 SVG 版。

常见问题

  • 为什么是金字塔? 底层应该是评审的基础,也应该占据评审的大部分时间。
  • 等等,这不是三角形吗? 看上去是,但这是从侧面看金字塔。
  • 你用哪个工具画的? Excalidraw。

English Original

The Code Review Pyramid

When it comes to code reviews, it’s a common phenomenon that there is much focus and long-winded discussions around mundane aspects like code formatting and style, whereas important aspects (does the code change do what it is supposed to do, is it performant, is it backwards-compatible for existing clients, and many others) tend to get less attention.

To raise awareness for the issue and providing some guidance on aspects to focus on, I shared a small visual on Twitter the other day, which I called the "Code Review Pyramid". Its intention is to help putting focus on those parts which matter the most during a code review (in my opinion, anyways), and also which parts could and should be automated.

As some folks asked for a permanent, referenceable location of that resource and others wanted to have a high-res printing version, I’m putting it here again:

code review pyramid

You can also download the visual as an SVG file.

FAQ

  • Why is it a pyramid?

    The lower parts of the pyramid should be the foundation of a code review and take up the most part of it.

  • Hey, that’s a triangle!

    You might think so, but it’s a pyramid from the side.

  • Which tool did you use for creating the drawing?

    Excalidraw.

posted @ 2026-12-04 13:14  西门咬狗  阅读(3)  评论(0)    收藏  举报