r/programming • • Aug 01 '26

The Bedrock of Software Design

https://alex.draftist.io/blog/the-bedrock-of-software-design-ycqvcedsj

I drafted this post years ago but didn’t finish it until now. The concept I write about has shaped the way I design software more than anything else, and I believe every software engineer should be introduced to it early in their career.

P.S. I don’t want the title to come across as clickbait: the post is about ADT.

447 Upvotes

70 comments sorted by

View all comments

Show parent comment

15

u/BaNyaaNyaa Aug 01 '26

To me, it really depends on how "normal" the error is. If I get in a state that shouldn't exist, I'd rather throw an error. If the error is expected (an API call to a 3rd party that fails), I'd rather return a result.

1

u/Zardotab Aug 11 '26

A rule of thumb is use conditionals for specific errors you can anticipate and "catch" for those you can't. In other words, when it doubt, use conditionals. Although, this advice may vary per language.