intermediate

Duplication management

Remove duplicated knowledge and policy while tolerating temporary similar code until the shared abstraction is stable.

Manage duplication by distinguishing shared knowledge from coincidental similarity. Extract libraries for stable policies; leave parallel code when product paths diverge. Track duplication in review—copy-paste across services is a future incident.

Tools (linters, copy-paste detectors) assist judgment; they do not replace domain understanding.

On interviews: decide extract vs tolerate for two similar validation blocks with different evolution.

Common pitfalls: mega-shared utils coupling teams, abstracting on syntax similarity alone, and forked business rules drifting apart silently.

The trade-off is single source of truth versus independent team velocity.

Checklist:

  • Extract shared business rules.
  • Tolerate cosmetic duplication temporarily.
  • Monitor cross-service copy-paste.