I'll Be Backend
Principles

Fail Fast: Validate at the Boundary

Fail fast means stopping at the first sign of bad input, before any work is done, and the boundary is where outside data enters the code. When each input is checked deep inside, where it's first used, a bad request fails halfway, after earlier lines have already changed state. These lessons take a ticket shop that takes seats before it looks at the email, move the parsing and input checks to the handler and the order's constructor, and the new email rule becomes one line in one place.

Pick your language

When to use it

Use it when

Data from outside, like a form, a file or an API call, flows into code that changes state.

Skip it when

The rule depends on current state, like sold out. Only the shop can check it, so keep it as a guard clause right before the change.

Spot it by

Raw strings passed deep into the code, input checks spread over inner methods, or a check that runs after a line changed state.