Why this matters
Failing fast reduces wasted I/O, keeps code paths simple, and prevents unnecessary transaction/connection usage.
Validate inputs and preconditions up-front and return early before issuing any database queries.
Failing fast reduces wasted I/O, keeps code paths simple, and prevents unnecessary transaction/connection usage.
Side-by-side examples engineers can pattern-match during review.
var user = await _db.Users.FindAsync(id);
if (id <= 0) return BadRequest();if (id <= 0) return BadRequest();
var user = await _db.Users.FindAsync(id);var row = ctx.Table.Find(id); if(!IsValid(id)) return;if(!IsValid(id)) return; var row = await ctx.Table.FindAsync(id);From the same buckets as this rule.