Three independently ugly bugs that all fed the same log flood:
* Electron's `WebFrameMain.send` writes every "Render frame was disposed"
to stderr via `console.error`. When the worker fans a second
agent-event past a reloading renderer, we produced thousands of
identical lines and stalled the main loop on stderr I/O. Added a
`mainFrame.detached` guard so the send is short-circuited before
Electron's own catch block fires, and installed a targeted filter in
`suppress-warnings.ts` (now actually imported from the entry point)
so the specific `console.error("Error sending from webFrameMain:"…)`
noise never reaches the terminal. Any other payload still surfaces.
* `dispatchAgentMessage` accepted the human-reader sentinel as a wake
target when an agent replied to `__board__` — `wakeAgentIfPossible`
then called `db.getAgent("__board__")`, threw, and the dispatcher
kept repeating on every send. Strip `HUMAN_SENDER_ID` at
`resolveMessageWakeTargets`, and keep a defense-in-depth guard in the
heartbeat so a stray caller (future automation fan-out) cannot
reintroduce the crash.
* Pi's skills loader rejects any SKILL.md whose frontmatter `name`
diverges from its parent directory. The four bundled `my-writing-style`
copies declared `name: writing-style-skill`, so every install emitted
a warning and dropped the skill. They also lived as orphan gitlinks
(mode 160000 without .gitmodules), and the global `*.md` gitignore
hid every other SKILL.md from version control. Fixed the frontmatter
to match the dir, converted the dangling submodules to plain trees,
and allowlisted `builtin-skills/**/*.md` so a fresh clone carries the
catalogue instead of silently losing it.
48 lines
1.5 KiB
Markdown
48 lines
1.5 KiB
Markdown
---
|
|
title: Use Intention-Revealing Names
|
|
impact: CRITICAL
|
|
impactDescription: eliminates mental mapping overhead
|
|
tags: name, intention, readability, clarity
|
|
---
|
|
|
|
## Use Intention-Revealing Names
|
|
|
|
Names should reveal intent. A name should tell you why something exists, what it does, and how it is used. If a name requires a comment, it does not reveal its intent.
|
|
|
|
**Incorrect (requires mental decoding):**
|
|
|
|
```java
|
|
int d; // elapsed time in days
|
|
|
|
public List<int[]> getThem() {
|
|
List<int[]> list1 = new ArrayList<>();
|
|
for (int[] x : theList)
|
|
if (x[0] == 4) // What is 4? What is x[0]?
|
|
list1.add(x);
|
|
return list1;
|
|
}
|
|
```
|
|
|
|
**Correct (self-documenting):**
|
|
|
|
```java
|
|
int elapsedTimeInDays;
|
|
|
|
public List<Cell> getFlaggedCells() {
|
|
List<Cell> flaggedCells = new ArrayList<>();
|
|
for (Cell cell : gameBoard)
|
|
if (cell.isFlagged())
|
|
flaggedCells.add(cell);
|
|
return flaggedCells;
|
|
}
|
|
```
|
|
|
|
The code now explicitly communicates its purpose: finding flagged cells in a minesweeper game. No comment needed.
|
|
|
|
**When short names are acceptable:**
|
|
- Loop counters (`i`, `j`, `k`) in small, tightly-scoped loops where the index has no domain meaning.
|
|
- Mathematical algorithms where `x`, `y`, `dx`, `dt` are conventional and understood by the target audience.
|
|
- Lambda parameters in trivial callbacks: `items.filter(x -> x > 0)` is clearer than `items.filter(numberThatMustBePositive -> numberThatMustBePositive > 0)`.
|
|
|
|
Reference: [Clean Code, Chapter 2: Meaningful Names](https://www.oreilly.com/library/view/clean-code-a/9780136083238/)
|