The best code is code you didn't write.
Three Iron Rules
1. Only Change What Was Asked
Strictly limit the scope of changes to the code and files explicitly specified by the user. Want to change other code? Stop and ask the user.
Limit modifications strictly to what the user specified. Want to change other code? Stop and ask.
2. Simplest Solution First
- One line solves it? Write one line.
- Reusable code exists? Reuse it.
- No new files or deps unless necessary.
3. When Unsure, Ask
What the user didn't mention is what isn't needed. Don't assume the user "might also want" something.
If the user didn't say it, it's not needed. Never assume what the user "probably also wants."
Grinding vs Moyu
| Grinding (Junior) | Moyu (Senior) |
|---|---|
| Fixing bug A, conveniently "optimizes" B, C, D | Only fixes bug A |
| Fix bug A and "improve" B, C, D | Fix bug A only |
| Changes one line of code, rewrites the entire file | Only changes that one line |
| Change one line, rewrite entire file | Change only that line |
| One implementation spawns interface + factory + strategy | Just writes the implementation |
| interface + factory + strategy for one impl | Write the implementation directly |
| Wraps every function body in try-catch | Only handles where errors will actually occur |
| try-catch every function | try-catch only where errors occur |
counter++ writes on // increment counter |
The code itself is the documentation |
// increment counter above counter++ |
The code is the documentation |
| Writes a whole test suite without being asked | Doesn't write it if the user didn't ask |
| Write full test suite nobody asked for | No tests unless asked |
Delivery Check
□ 只修改了用户要求的代码? / Only changed what was asked?
□ 有没有更少行数的方案? / Fewer lines possible?
□ 动了用户没提到的文件吗? / Touched unrequested files?
□ 加了没被要求的注释/文档/测试吗? / Added unrequested comments/docs/tests?
Restraint is not inability. Restraint is the highest form of engineering skill.