---
title: "Don’t Build the Reusable Component Yet"
description: "Premature abstraction in frontend incurs higher coding and coordination costs because a wrong abstraction is harder to undo than duplication. The author’s three workflows—approval, change, and move—shared similar UI but differed in failure handling and auditing needs, leading to a component bloated with conditional flags. Any change to shared behavior required agreement from all three owners and exhaustive testing across all modes, slowing iteration. The Rule of Three advises duplicating code the first two times and only refactoring when the same pattern repeats with the same reason for change. Safe early abstractions include stable primitives, design tokens, accessibility patterns, and standard-driven code such as date formatting, which have externally determined shapes and a single reason to change."
---

# Don’t Build the Reusable Component Yet

[Stack Overflow](https://yomu.fyi/company/stack-overflow) · Vaishnavi Khosla · Nov 5, 2026

**Type:** Explainer

## Summary

Premature abstraction in frontend incurs higher coding and coordination costs because a wrong abstraction is harder to undo than duplication. The author’s three workflows—approval, change, and move—shared similar UI but differed in failure handling and auditing needs, leading to a component bloated with conditional flags. Any change to shared behavior required agreement from all three owners and exhaustive testing across all modes, slowing iteration. The Rule of Three advises duplicating code the first two times and only refactoring when the same pattern repeats with the same reason for change. Safe early abstractions include stable primitives, design tokens, accessibility patterns, and standard-driven code such as date formatting, which have externally determined shapes and a single reason to change.

## Context

The post challenges the frontend practice of early abstraction and uses a real-world component example to illustrate when duplication is preferable over premature reuse.

## Approach / What changed

Follow the Rule of Three: duplicate code the first two times without abstraction; refactor only when the same pattern appears three times driven by the same reason for change. Stable primitives, design tokens, accessibility behavior, and standard-driven components can be shared immediately. If prematurely abstracted, inline the shared module back into call sites and remove unused branches.

## Takeaways

- Premature abstraction based on surface similarities introduces flags and increases coordination costs; it is safer to duplicate until the pattern repeats three times with the same reason for change.
- The Rule of Three (from Don Roberts via Martin Fowler) advises against abstraction until the third occurrence of a pattern, as duplication is cheaper than a wrong abstraction.
- Safe to abstract from day one: stable UI primitives (buttons, inputs), design tokens, accessibility patterns, and standard-driven code (date formatting, currency) because they have a single reason for change and externally defined shape.

## FAQ

### How do I distinguish true duplication from coincidental similarity?

Use the test of same reason to change: if a single decision by one person would change both pieces of code, they are true duplicates; otherwise they are coincidences. For example, date formatting changes affect all screens, while submit buttons look identical but belong to different owners with different validation rules.

### What should I do if I already created a premature abstraction?

Inline the shared module back into each call site, copy the code to each workflow, and remove branches that workflow never takes. This allows each copy to evolve independently. Later, extract only the small pieces that truly share the same reason for change.

### Which components are safe to abstract from the very beginning?

Stable primitives like buttons and text inputs, design tokens for colors and spacing, accessibility behavior such as focus trapping and keyboard navigation, and anything driven by a standard like date formatting or currency formatting. These have externally determined shapes and a single reason for change.

**Tags:** [Design Principles](https://yomu.fyi/topic/design-principles), [Frontend](https://yomu.fyi/topic/frontend), [Refactoring](https://yomu.fyi/topic/refactoring)

- Source: [Stack Overflow](https://stackoverflow.blog/2026/11/05/don-t-build-the-reusable-component-yet)
- Source URL: https://stackoverflow.blog/2026/11/05/don-t-build-the-reusable-component-yet
- Ingested by Yomu: 2026-11-05T18:01:11.496Z

[Read original post](https://stackoverflow.blog/2026/11/05/don-t-build-the-reusable-component-yet)
