er阅读约 6 分钟

ER modeling for code reviewers

Reading crow's-foot like a database engineer.

TL;DR

If your diagram has a clear direction of time, reach for a sequence. If it has decision points, use a flowchart. If you find yourself drawing both, your diagram is doing too much — split it.

Why this matters

The single biggest mistake we see in code review is teams reaching for whichever diagram type they remember the syntax for. The result is a flowchart pretending to be a sequence diagram, or vice versa, and the reader spends 30 seconds decoding the metaphor before they even read the content.

The right diagram type makes the rest of the work easier. The wrong one makes everything harder.

A worked example

Suppose you're documenting an OAuth2 authorization-code flow. Each step is a message between actors, and the order is critical:

oauth.mmd
sequenceDiagram
    autonumber
    participant U as User
    participant W as Web app
    participant A as API
    participant D as Database
    U->>W: Click class="code-str">"Save"
    W->>A: POST /diagrams
    A->>D: INSERT INTO diagrams
    D-->>A: id = 4f2…
    A-->>W: 201 Created
    W-->>U: ✓ Saved
UserAPIDBGET /meSELECT…row200 OK

Now compare with the equivalent in a flowchart — same information, much harder to read because the time axis is gone:

startok?retrycommitenddone

Three rules of thumb

  1. Direction of time matters? Sequence diagram.
  2. Branching with decisions? Flowchart.
  3. Hierarchical relationships? Class or ER diagram.

Next steps

下一篇
C4 architecture in three diagrams
阅读全文