You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/reference/SIMPLE-DESIGN.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,29 @@
1
-
# Kent Beck's Four Rules of Simple Design
1
+
# Kent Beck's four rules of simple design
2
2
3
-
These rules provide objective criteria for evaluating code design. They're in priority order—higher rules take precedence over lower ones when they conflict.
3
+
These rules provide objective criteria for evaluating code design. They're in priority order: higher rules take precedence over lower ones when they conflict.
4
4
5
-
## Rule 1: Passes the Tests
5
+
## Rule 1: Passes the tests
6
6
7
7
**The code must work as intended.**
8
8
9
9
- All functionality proven through automated tests
10
10
- Nothing else matters if the system behaves incorrectly
11
11
- Tests provide confidence to refactor and improve design
12
-
- Avoid tests that only verify implementation details—tests should assert correct behavior
12
+
- Avoid tests that only verify implementation details. Tests should assert correct behavior
13
13
14
-
**Example**: Before optimizing SQL parsing or parameter binding logic, ensure comprehensive tests prove correctness across all supported SQLite data types and edge cases.
14
+
**Example**: Before optimizing SQL parsing or parameter binding logic, ensure tests prove correctness across all supported SQLite data types and edge cases.
15
15
16
-
**Pitfall**: Don't skip tests for "simple" changes—SQLite has countless edge cases across different data types, encoding scenarios, and concurrent access patterns.
16
+
**Pitfall**: Don't skip tests for "simple" changes. SQLite has countless edge cases across different data types, encoding scenarios, and concurrent access patterns.
17
17
18
-
## Rule 2: Reveals Intention
18
+
## Rule 2: Reveals intention
19
19
20
20
**Code should clearly express what it does and why.**
21
21
22
22
- Use descriptive names for variables, functions, and types
23
23
- Structure code to match the problem domain
24
24
- Prioritize readability for future maintainers
25
25
26
-
## Rule 3: No Duplication
26
+
## Rule 3: No duplication
27
27
28
28
**Eliminate repeated logic and knowledge.**
29
29
@@ -33,9 +33,9 @@ These rules provide objective criteria for evaluating code design. They're in pr
33
33
34
34
**Example**: Instead of duplicating SQLite type conversion logic across DatabaseSync and StatementSync classes, extract the conversion functions to a shared utility module.
35
35
36
-
**Pitfall**: Don't create premature abstractions—sometimes temporary duplication is acceptable while understanding emerges, especially when porting code from Node.js internals.
36
+
**Pitfall**: Don't create premature abstractions. Sometimes temporary duplication is acceptable while understanding emerges, especially when porting code from Node.js internals.
37
37
38
-
## Rule 4: Fewest Elements
38
+
## Rule 4: Fewest elements
39
39
40
40
**Remove anything that doesn't serve the first three rules.**
41
41
@@ -45,7 +45,7 @@ These rules provide objective criteria for evaluating code design. They're in pr
45
45
46
46
**Example**: Don't build a complex caching layer for prepared statements until profiling shows it's actually a bottleneck, and don't create wrapper abstractions for SQLite features until multiple use cases demonstrate the need.
47
47
48
-
**Pitfall**: Don't over-apply this rule—necessary complexity is still necessary. Native code interop and memory management require inherent complexity.
48
+
**Pitfall**: Don't over-apply this rule. Necessary complexity is still necessary. Native code interop and memory management require inherent complexity.
49
49
50
50
## Rule 5: No bogus guardrails or defaults
51
51
@@ -55,19 +55,19 @@ When key assumptions that your code relies upon to work appear to be broken, fai
55
55
- If you are fairly certain data should always exist, assume it does, rather than producing code with unnecessary guardrails or existence checks (esp. if such checks might mislead other programmers)
56
56
- Never use 'defaults' as a result of errors, either for users, or downstream callers.
57
57
58
-
## Priority and Conflicts
58
+
## Priority and conflicts
59
59
60
60
**When rules conflict, higher numbers win:**
61
61
62
62
- Working code (Rule 1) beats everything
63
63
- Clear names (Rule 2) and no duplication (Rule 3) often reinforce each other
64
-
- The "duplication vs clarity" debate misses the point—both improve together over time
64
+
- The "duplication vs clarity" debate misses the point. Both improve together over time
65
65
66
66
**Common conflict**: During refactoring, you might temporarily duplicate code to pass tests, then eliminate duplication while improving names.
67
67
68
68
**Exception**: In test code, empathy for readers sometimes trumps technical purity.
Copy file name to clipboardExpand all lines: doc/reference/TPP-GUIDE.md
+55-55Lines changed: 55 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
# Technical Project Plan (TPP) Guide
1
+
# Technical project plan (TPP) guide
2
2
3
3
## Purpose
4
4
5
-
A TPP transfers expertise, not just instructions. A great TPP lets another engineer complete the work without asking questions—even if the code changed since you wrote it.
5
+
A TPP transfers expertise, not just instructions. A great TPP lets another engineer complete the work without asking questions, even if the code changed since you wrote it.
6
6
7
7
**The golden rule**: If an implementer fails because context was missing from your TPP, that's your failure, not theirs.
8
8
9
-
## Required Reading
9
+
## Required reading
10
10
11
11
Before writing any TPP, read and incorporate:
12
12
@@ -15,9 +15,9 @@ Before writing any TPP, read and incorporate:
15
15
16
16
These are not optional. TPPs that ignore them will be rejected.
17
17
18
-
## TPP Structure
18
+
## TPP structure
19
19
20
-
### Part 1: Define Success (5 minutes max)
20
+
### Part 1: Define success (5 minutes max)
21
21
22
22
Write one clear sentence for each:
23
23
@@ -26,7 +26,7 @@ Write one clear sentence for each:
26
26
**Why it matters**: Breaks compatibility with node:sqlite which returns []
27
27
**Solution**: Match node:sqlite behavior in StatementSync::All()
28
28
**Success test**: `npm t -- --grep "empty result"`
29
-
**Key constraint**: Must match node:sqlite exactly—test against Node.js built-in
29
+
**Key constraint**: Must match node:sqlite exactly. Test against Node.js built-in
30
30
```
31
31
32
32
This is your North Star. Implementation details may change; the user need stays constant.
@@ -40,7 +40,7 @@ This is your North Star. Implementation details may change; the user need stays
| Resource cleanup | Jest hangs | Close all databases in afterEach |
188
188
189
-
### Platform-Specific Failures
189
+
### Platform-specific failures
190
190
191
191
Document when behavior varies:
192
192
193
193
```markdown
194
-
**Windows**: File locks persist longer—use retry logic in cleanup
195
-
**Alpine ARM64**: 10x slower in CI—use`getTestTimeout()` for timing tests
196
-
**macOS**: VM performance varies—avoid exact timing assertions
194
+
**Windows**: File locks persist longer. Use retry logic in cleanup
195
+
**Alpine ARM64**: 10x slower in CI. Use`getTestTimeout()` for timing tests
196
+
**macOS**: VM performance varies. Avoid exact timing assertions
197
197
```
198
198
199
-
## Anti-Patterns to Avoid
199
+
## Anti-patterns to avoid
200
200
201
-
### "It Works" Without Proof
201
+
### "It works" without proof
202
202
203
203
Bad: "I tested it and it works"
204
204
Good: "Test passes: `npm t -- --grep 'specific test name'`"
205
205
206
-
### Shelf-ware Code
206
+
### Shelf-ware code
207
207
208
208
Implementation exists but nothing uses it. Every feature needs integration proof:
209
209
@@ -212,25 +212,25 @@ Implementation exists but nothing uses it. Every feature needs integration proof
212
212
grep -r "newFunction" src/ test/ # Must appear in both
213
213
```
214
214
215
-
### The 95% Trap
215
+
### The 95% trap
216
216
217
-
"Just needs cleanup" = 50% more work. Tasks are complete or incomplete—no percentages.
217
+
"Just needs cleanup" = 50% more work. Tasks are complete or incomplete. No percentages.
218
218
219
-
### Bogus Guardrails
219
+
### Bogus guardrails
220
220
221
221
Per [SIMPLE-DESIGN.md](./SIMPLE-DESIGN.md) Rule 5: Don't add defensive code for impossible cases. If assumptions are violated, fail visibly.
222
222
223
-
### Testing the Wrong Thing
223
+
### Testing the wrong thing
224
224
225
225
Bad: "Added test for NULL handling" (but test exercises `SQLITE_NULL` type, not NULL pointer from extraction failure)
226
226
227
-
Good: "Added regression test for TEXT/BLOB paths. The actual NULL-pointer edge case is untestable—validated via code review against `aggregate_function.cpp:515-530`"
227
+
Good: "Added regression test for TEXT/BLOB paths. The actual NULL-pointer edge case is untestable. Validated via code review against `aggregate_function.cpp:515-530`"
228
228
229
229
Be precise about what your test actually validates vs. what remains validated only by code review.
230
230
231
-
## Validation Requirements
231
+
## Validation requirements
232
232
233
-
### Required Evidence Types
233
+
### Required evidence types
234
234
235
235
Every checkbox needs proof another engineer can verify:
236
236
@@ -239,7 +239,7 @@ Every checkbox needs proof another engineer can verify:
239
239
-**Integration proof**: `grep` commands showing production usage
240
240
-**Behavior comparison**: Test output against node:sqlite
241
241
242
-
### Completeness Validation
242
+
### Completeness validation
243
243
244
244
For fixes that apply to multiple locations, the TPP must include a scope check:
245
245
@@ -254,7 +254,7 @@ A fix for one instance that misses others is incomplete. Document:
254
254
- Which files contain them
255
255
- Validation that ALL were addressed
256
256
257
-
### Definition of Complete
257
+
### Definition of complete
258
258
259
259
A task is complete when:
260
260
@@ -264,7 +264,7 @@ A task is complete when:
264
264
4. All validation commands pass
265
265
5.`npm t` shows no regressions
266
266
267
-
### Common Over-Selling Patterns
267
+
### Common over-selling patterns
268
268
269
269
Do NOT mark complete if:
270
270
@@ -273,7 +273,7 @@ Do NOT mark complete if:
273
273
- "Ready for review" but `npm run lint` fails
274
274
- "Feature complete" but old path still active
275
275
276
-
## Quality Checklist
276
+
## Quality checklist
277
277
278
278
Before marking your TPP ready:
279
279
@@ -282,41 +282,41 @@ Before marking your TPP ready:
282
282
-[ ] Documented at least one "learned the hard way" lesson
283
283
-[ ] Each task has verifiable success command
284
284
-[ ] Explained how to adapt if code was refactored
285
-
-[ ] Bug fixes start with failing test ([TDD.md](./TDD.md))—or document why TDD isn't possible
285
+
-[ ] Bug fixes start with failing test ([TDD.md](./TDD.md)), or document why TDD isn't possible
286
286
-[ ] Code follows Four Rules ([SIMPLE-DESIGN.md](./SIMPLE-DESIGN.md))
287
287
-[ ] API compatibility with node:sqlite verified
288
288
-[ ] If fix applies to multiple locations, included grep to find ALL instances
289
289
-[ ] Test descriptions clarify what IS and ISN'T covered
290
290
291
-
## The Ultimate Test
291
+
## The ultimate test
292
292
293
-
Hand this TPP to someone unfamiliar with the codebase. If they can implement the solution without asking questions—even if the code was refactored—you've written an excellent TPP.
293
+
Hand this TPP to someone unfamiliar with the codebase. If they can implement the solution without asking questions, even if the code was refactored, you've written an excellent TPP.
294
294
295
-
## TPP Template
295
+
## TPP template
296
296
297
297
Copy this structure for new TPPs--but omit sections that aren't relevant or helpful.
298
298
299
299
```markdown
300
300
# TPP: [Specific Project Name]
301
301
302
-
## Goal Definition
302
+
## Goal definition
303
303
304
-
-**What Success Looks Like**: [1 sentence]
305
-
-**Core Problem**: [1 sentence]
306
-
-**Key Constraints**: [1 sentence—include API compatibility requirement]
307
-
-**Success Validation**: [1 sentence—include test command]
304
+
-**What success looks like**: [1 sentence]
305
+
-**Core problem**: [1 sentence]
306
+
-**Key constraints**: [1 sentence, include API compatibility requirement]
307
+
-**Success validation**: [1 sentence, include test command]
0 commit comments