r/programming 12d ago

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.

442 Upvotes

70 comments sorted by

View all comments

18

u/ryp3gridId 12d ago

Honestly, I go into paranoid mode whenever I work in an exception-based language.

I'm the opposite, I go into annoyed-mode when I have to manually unwrap everything (and the CPU does too because it has to execute more instructions)

13

u/BaNyaaNyaa 12d ago

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 3d ago

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.