Turn a Repeated Mistake Into a Check
Описание и применение
Разработчики многократно копируют шаблоны чтения из БД, создавая 44 дублирующих блока кода. Внедрение единого обобщённого типа Reader и инструментальных проверок устраняет дублирование и предотвращает будущие ошибки.
Задача
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.
Результат
Reduced code duplication from 44 instances to a single generic implementation, improving maintainability and preventing future mistakes.
Рабочий процесс
- 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
Доказательства
44 copies of four shapes of reading rows out of the database.
The rule said "don't copy a generic".
- Дата записи: 2026-09-15T17:30:38.297Z