Turn a Repeated Mistake Into a Check
Description and use
Developers repeatedly copy database read patterns, creating 44 duplicated code blocks. Introducing a single generic Reader type and tooling checks eliminates duplication and prevents future mistakes.
Problem
Developers repeatedly copy generic database read patterns, creating 44 duplicated code blocks that differ only in error messages, leading to maintenance overhead and hidden bugs.
Outcome
Reduced code duplication from 44 instances to a single generic implementation, improving maintainability and preventing future mistakes.
Workflow
- Audit code for duplicate read patterns
- Identify existing generic Reader implementation
- Refactor duplicated code to use Reader
- Add tooling checks (linter, tests, blocking hooks) to enforce non‑duplication
Evidence
44 copies of four shapes of reading rows out of the database.
The rule said "don't copy a generic".
- Record date: 2026-09-15T17:30:38.297Z