Defensive Programming and the Fail-First Approach

Anyone who has written software knows that code is error-prone by nature. There are so many things that can go wrong — users inputting invalid values, code which is executed based on wrong assumptions causing the software to fail, and the list goes on.

A really bad mindset in programming is to assume that things will always “work out”, that objects and data will be present and…