🤖 The Modern AI Developer · Modern Code Review

What Does Code Review Actually Check? The Three Layers

Correctness, maintainability, team conventions—each layer harder than the last

一句话先懂 · TL;DR

Code review goes far beyond typo hunting: correctness, maintainability, and team conventions form three layers, each harder than the last, explained simply.

Reviewing Code Isn't Hunting for Typos

Many people, reviewing code for the first time, think it's about finding where it's written wrong or whether the indentation is right. Real code review answers three entirely different questions: can this code run correctly, will it be easy to change later, and does it follow the team's rules.

🔆It's like inspecting a newly renovated home: first check whether the water and electricity work (correctness), then whether the layout and flow make sense (maintainability), and finally whether it was built per the property rules (team conventions).

These three layers, from bottom to top, get more abstract and harder to judge with each step.

Layer One: Can It Run Correctly

Correctness is the foundation: is the logic right, are edge cases handled, will an exception crash the program. Get this layer wrong and no matter how pretty the code is, it's useless.

def average(nums):
    return sum(nums) / len(nums)

# 传进来一个空列表会怎样?
average([])  # ZeroDivisionError!
⚠️Empty input, huge input, negatives, None—these edge cases are what correctness review should watch most closely.

Layers Two and Three: Easy to Maintain, Compliant with the Rules

Maintainability cares about you and your colleagues six months from now: are the variable names understandable, are functions too long, is there duplicated code. Code that runs now but can't be read or changed is debt you've taken on.

Team conventions are the topmost layer: how comments are written, how files are named, whether to use a certain library—these have no absolute right or wrong, only "this is how this team decided."

💡The higher you go, the harder it is to hand to a machine: a machine can test whether it runs, but "is this name clear enough" often has to be judged by a person.

自测 · 学完检查一下

想真正动手做题、记进度、攒连胜?到互动课里练。

What's the correct order of code review's three layers, from bottom to top?

答案:Correctness → maintainability → team conventions

The foundation is "can it run correctly," then "is it easy to maintain," and only at the top "does it follow team conventions."

"This function doesn't handle being passed an empty list"—which layer does this problem belong to?

答案:Correctness

An empty list is a classic edge case; mishandling it makes the program error out—it belongs to the "can it run correctly" correctness layer.

"Variable names like `a`, `b`, `tmp2` everywhere, so no one can read it"—which layer is this?

答案:Maintainability

The code runs, but bad naming makes future edits painful—it belongs to the "is it easy to maintain" layer.

Judge: "the team requires a one-line doc comment on every public function, and this code has none"—this belongs to the team-conventions layer.

答案:Correct

Comment-format rules of the "the team decided it this way" kind have no absolute right or wrong—they belong to the team-conventions layer.

Judge: compared with "does the program run correctly," "is this name clear enough" is harder to fully hand to a machine to judge.

答案:Correct

Whether it runs correctly can be auto-verified by tests, while whether a name is clear often needs human contextual judgment—the higher the layer, the harder to automate.

Among the three layers of code review, the foundation that must be guaranteed first is ____ness.

答案:correct

Correctness is the foundation; if the code can't even run right, maintainability and team conventions are moot.

想边练边学,而不只是读?

到互动课里答题、记进度、攒连胜——游客即可试学,无需注册。

进入互动课程 →

Learn something new — don't miss updates

New courses, features and learning tips. Occasional emails, unsubscribe anytime.