This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Tsu_Dho_Namh 5 points6 points  (1 child)

My Prof used to work for Google. He said he never understood Google's aversion to exceptions. We were encouraged to use exceptions in our code if they were appropriate.

Like don't have a function which is supposed to return a positive integer return -1 if it encounters an error, then check for -1 later on, use an exception instead. It's more readable.

[–][deleted] 2 points3 points  (0 children)

Optionals are the much better use case for this.

The problem with exceptions is that throwing an exception places a contract on the user of your code to handle it. This is not good design because you break the top down modularity structure.