Briefle words · Code & architecture
Fail fast
Stopping with a clear error as soon as something is wrong, instead of carrying on and failing later in a confusing way.
Say it to an AI
Python function book_shipment(order, weight_kg, postcode). Fail fast: guard clauses at the top validate the weight (0–1000 kg) and the UK postcode and raise ValidationError before any side effects, like reserving a truck slot or creating the carrier label.
How an expert would brief the stronger version of “Shipment booking”.
See it
Try it as a puzzle →Backend function that books a courier pickup for an online order in a logistics platform.
Why: B raises ValidationError before any work is done. A only fails on line 7, inside rates.quote(), after two other systems were already called.
Related words
Room 4 · Errors & edge cases
Learn “Fail fast” in a five-minute lesson