跳转至

技术写作

等级 L2 · 每天 15 分钟 · 场景:写邮件→一、英文邮件,写PR→二、PR 描述,写设计文档→三、设计文档,写注释→四、代码注释

模板先行,渐进去模板。 写作不是翻译,是直接用英文组织思路。先用模板找到感觉,再逐步替换为自己的句子。


学习地图

场景 核心原则 关键模板
英文邮件 标题写清楚,正文三句话内说完 请求/回复/跟进/感谢
PR 描述 What + Why + How 三段式模板
设计文档 Problem → Solution → Trade-offs RFC 模板
代码注释 写 Why 不写 What 一句话原则
技术博客 先写大纲,再填充 How-to / Deep-dive

一、英文邮件

核心原则

  1. 标题写清楚:收件人看标题就知道要做什么
  2. 正文三句话内:谁+什么事+要对方做什么
  3. 语气礼貌但不啰嗦:用 could/would 软化语气,不要堆砌 please

常用动词

动词 场景 例句
follow up on 跟进 I'm following up on the PR review.
look into 调查 I'll look into the issue and get back to you.
loop in 拉入讨论 Looping in @Alice from the platform team.
ping 提醒 Just pinging on this — any updates?
circle back 回头再聊 Let's circle back on this in the next meeting.
sync up 同步 Let's sync up on the deployment plan.
heads up 提前告知 Heads up: we're deploying at 3pm today.
bump 顶一下 Bumping this thread since the deadline is Friday.

模板

请求帮助:

Subject: Question about [具体问题]

Hi [Name],

[一句话背景].

Could you take a look at [具体内容] when you have a moment?
[可选: 为什么需要帮助 / 截止时间]

Thanks!
[Your Name]

回复确认:

Subject: Re: [原标题]

Hi [Name],

Got it, thanks. I'll [下一步动作] by [时间].

[Your Name]

跟进(没收到回复):

Subject: Re: [原标题]

Hi [Name],

Just following up on this — any thoughts?
No rush if you're busy.

Thanks!
[Your Name]

感谢:

Subject: Thanks for [具体事]

Hi [Name],

Thanks for [具体帮助] — [简短说明为什么有帮助].

[Your Name]

通知(不期待回复):

Subject: [FYI] [简短描述]

Hi team,

Just a heads up: [变更内容].

[可选: 影响范围 / 链接]

No action needed.
[Your Name]


二、PR 描述

三段式模板

## What

[做了什么,一句话]

## Why

[为什么这样做,1-2 句]

## How

[怎么做的,可选:关键改动点]

- [改动 1]
- [改动 2]

## Test

[怎么测试的]

- [ ] Unit tests passed
- [ ] Tested locally with [场景]

示例

## What

Add retry logic to the payment service for transient network errors.

## Why

The payment gateway occasionally returns 503 errors during peak hours.
Retrying once with exponential backoff reduces the failure rate from 0.5% to < 0.01%.

## How

- Added `RetryableRestTemplate` with max 3 retries and exponential backoff
- Made retry behavior configurable via `application.yml`
- Added metrics for retry attempts and success rate

## Test

- [x] Unit tests for retry logic
- [x] Integration test with WireMock simulating 503 → 200
- [x] Tested locally with 1000 concurrent requests

PR 评论常用语

场景 评论
同意 LGTM! (Looks Good To Me)
小建议 Nit: [小建议] (nit = nitpick,小挑剔)
建议改 Suggestion: [建议]
需要改 Please [要求]. Otherwise [可能的后果].
问问题 Question: [问题]
感谢 Nice catch! / Good point.
不理解 I'm not sure I follow — could you elaborate?
不同意但尊重 I see your point, but I'd lean toward [方案] because [理由]. Let me know what you think.

三、设计文档

模板

# [Title]: [一句话描述]

**Author**: [Name]
**Date**: [YYYY-MM-DD]
**Status**: Draft | In Review | Approved | Implemented

## Problem

[当前存在的问题,用数据说话]

## Goals & Non-Goals

**Goals:**
- [目标 1]
- [目标 2]

**Non-Goals:**
- [不做什么,划定范围]

## Proposed Solution

[方案描述,配图/伪代码]

## Alternatives Considered

| 方案 | Pros | Cons | 结论 |
|------|------|------|------|
| [方案 A] | ... | ... | ❌ [原因] |
| [方案 B] | ... | ... | ✅ Chosen |

## Trade-offs

[选择这个方案要付出的代价]

## Migration Plan

[如何从旧方案迁移到新方案]

## Open Questions

- [待解决的问题]

常用句式

场景 句式
描述问题 Currently, [问题]. This leads to [后果].
提出方案 We propose [方案], which [怎么解决问题].
对比方案 Alternative A does [优点], but [缺点].
说明权衡 This approach trades off [牺牲什么] for [获得什么].
划定范围 This design does NOT cover [范围外的事].
迁移计划 The migration will be done in [N] phases: [Phase 1], [Phase 2], ...

四、代码注释

核心原则

写 Why,不写 What。 What 代码已经说了,Why 才是读者需要知道的。

反面示例 vs 正面示例

反面(写 What) 正面(写 Why)
// increment counter // Count retries to detect flaky downstream
// check if null // user can be null when called from the batch job
// sleep 100ms // Rate limit: downstream allows 10 req/s max

类/方法注释

/**
 * Retries a failed HTTP request with exponential backoff.
 *
 * Used for idempotent GET requests to tolerate transient network errors
 * without overwhelming the downstream service.
 *
 * @param request  the HTTP request to retry
 * @param maxRetries  maximum number of retry attempts (default: 3)
 * @return the response, or throws the last exception if all retries fail
 */
public Response retryWithBackoff(Request request, int maxRetries) { ... }

注释常用动词

动词 场景
represents 表示某个概念
holds 持有/存储
wraps 包装
delegates to 委托给
ensures 确保
prevents 防止
falls back to 回退到
abstracts 抽象

五、技术博客

两种常见结构

How-to(教程型): 1. Problem: 你想解决什么问题 2. Prerequisites: 需要什么环境/知识 3. Step 1 → Step 2 → Step 3 4. Result: 最终效果 5. Gotchas: 踩过的坑

Deep-dive(深挖型): 1. Hook: 一个反直觉的事实或问题 2. Background: 为什么这个问题值得探究 3. Investigation: 你是怎么深入研究的 4. Findings: 发现了什么 5. Takeaways: 读者可以带走什么

常用句式

场景 句式
开头 Hook Have you ever wondered why [问题]?
引出问题 Let's say you're building a [系统] and you run into [问题].
过渡 Here's where things get interesting.
强调 The key insight here is that [核心认知].
总结 In a nutshell, [一句话总结].
收尾 I hope this helps! Feel free to reach out if you have questions.

写作速查:高频动词

中文 英文 例句
实现了 implemented Implemented the caching layer.
修好了 fixed / resolved Fixed the null pointer issue.
优化了 optimized / improved Optimized the query by adding an index.
重构了 refactored Refactored the payment module.
添加了 added / introduced Added retry logic.
移除了 removed / deprecated Removed the unused endpoint.
升级了 upgraded / bumped Upgraded Spring Boot to 3.4.
修复了 patched / fixed Patched the security vulnerability.
合并了 merged Merged the feature branch.
部署了 deployed / rolled out Deployed to production.
回滚了 rolled back / reverted Rolled back the deployment.

常见追问

先写中文再翻译可以吗?

不建议。 中英文的思维结构不同:中文先铺背景再结论,英文先结论再背景。先写中文再翻译,产出的是 Chinglish。建议直接用英文写,哪怕只有简单句。写多了自然就习惯了。

语法错误多怎么办?

用 Grammarly。 免费版就能覆盖 90% 的语法错误。写完后贴进去,看它标出来的地方,改完再发。三个月后你会发现自己犯的错误越来越少。

怎么写得"地道"?

读同事写的英文邮件和 PR,收藏好的表达。 建一个"好英文"文档,遇到好的句式就复制进去。写的时候翻出来参考。地道不是"背出来的",是"看多了自然会的"。


相关