A rule-based organization pattern turns refactoring into a repeatable sequence: define structural rules, reshape existing code, audit the result, and report its organization. It makes vague judgments about readability concrete enough for consistent human or AI-assisted application. section 2.5
Define rules for:
- Chunks: identify meaningful steps, reject fragments without standalone meaning, and split blocks that combine recognizable operations. section 2.5
- Method extraction: extract only when naming, abstraction consistency, complexity, repetition, or chunk limits improves readability; avoid extraction that adds navigation cost. section 2.5
- Narrative levels: specify chunk budgets, permitted lower-level calls, and supporting logic so methods receive consistent classifications. section 2.5
A chunk is a meaningful unit of code that reads as a single recognizable step, such as a method call, a conditional block, a loop, an error-handling block, a pipeline, or a system-boundary interaction. A chunk is too small when it has no meaning on its own (a setup assignment, a single arithmetic operation). A chunk is too large when it combines several recognizable steps: - two unrelated decisions in the same block - validation and persistence together - multiple system-boundary interactions grouped - a branch body that contains more than one expression
Use the supplied chunk, extraction, and Scene-level criteria as a compact rule set for auditing organization. section 2.5
