Track 04 · Lesson 15 of 15Code that stays easy to change

Track 04 · Code that stays easy to change

When they disagree

Lesson 15 of 15· 5 min

These principles pull against each other. That's expected: they're questions to ask, not laws to obey. Here are the three tensions you'll meet most often. Pick a side in each, then see what experienced engineers usually do.

Three real dilemmas

Pick a side in each

  1. DRY versus simple

    Two components each have a six-line helper that formats dates. One formats invoice dates the way your accountant requires; the other shows “3 days ago” in the UI. They look almost identical.

  2. Single responsibility versus YAGNI

    A 40-line settings component works and is easy to read. A reviewer asks you to split it into five files “for single responsibility”. Nothing about it is changing for a second reason yet.

  3. Fail fast versus a calm interface

    The prices API starts returning malformed data in production. Your boundary check catches it. What should the customer see?

DRY versus simple#

Removing duplication adds an abstraction. If the abstraction is harder to follow than the copies, keep the copies. Many teams wait for the third repeat, when the shared rule is clear.

Single responsibility versus YAGNI#

Splitting a 40-line component into five files "for responsibility" is its own kind of speculation. Split when a second reason to change actually shows up.

Fail fast versus a calm interface#

Be loud at the boundary, in development and in your logs. In front of a user, catch the error and offer a way forward. Loud for developers, calm for users.

The tiebreaker#

When principles disagree, ask which version a teammate could read, change and trust most easily, six months from now, without you in the room. That's usually the answer.

Check yourself

Two helpers look identical, but one serves the accountant and one serves the designer. What does experience suggest?