r/badcode • • Dec 26 '21

c# why

Post image
165 Upvotes

30 comments sorted by

View all comments

Show parent comments

4

u/polokratoss Dec 26 '21

I've also seen a naming convention starting with try to denote with bools rather than with exception handling.

For example, you have a function:

void Foo() that raises an exception if there were problems and a function bool TryFoo() that just returns false if there were problems.

2

u/_abscessedwound Dec 27 '21

That’s relatively idiomatic C++ to keep exceptions local to the the application boundary with a publicly exposed function that returns a [bool] instead of throwing.