Skip to content

clean-code

6 posts with the tag “clean-code”

Guard clauses in one line — getting started with Argument.Check

Fifteen lines of if/throw in front of three lines of real work, exception messages that name the wrong parameter after a rename, and a debugger that stops in the guard instead of in your code. How Argument.Check turns every guard clause into one readable line that returns the checked value, and what it does for you behind that line.

The Throw catalogue — every check in Argument.Check, with real messages

Null checks are the easy part. The interesting guards are the ones for strings, collections, ranges, files and types, plus your own rules in one line. A tour of every Throw helper in Argument.Check, grouped by what you check, with the exact exception each one throws and the handful of details you should know before you rely on them.