DEV Community

Discussion on: Is “Defensive Programming” actually healthy?

Collapse
 
robdwaller profile image
Rob Waller

Useful post, but I'm not sure defensive programming has anything to do with fear, it's more, as you touch on, to do with professionalism. We're paid to produce good software, and part of that is minimising bugs. Simply put defensive programming helps minimise bugs.

Collapse
 
cubiclebuddha profile image
Cubicle Buddha

Yes I agree, and thank you for weighing in. But I firmly believe that happiness comes from living in the present. So it’s a fun intellectual problem that I’ll be exploring in future posts.

My currently conclusion is that by being proactive in your code you can live more freely. And in a sense that’s the happiest way to live right now.

But I suppose one can go “too far” with defensive coding in which case it helps to have good teammates that call it out. It’s all a balance, right?

Collapse
 
robdwaller profile image
Rob Waller

I believe that's what Aristotle said. ;)

Trying to find a balance is usually the best approach.