3 ms·
> Exceptions are not too bad, but they are very often misused. This! The worst is when people start using them to control the flow of business logic. I hate th
by insulanian 10y ago
> Exceptions are not too bad, but they are very often misused.
This! The worst is when people start using them to control the flow of business logic. I hate that.
- cousin_it 10y agoJust wait until the same people get hold of monads to implement their business logic.
- nerdponx 10y agoWhat actually is so bad about doing this? I'm a data scientist, not the software engineer, so forgive me if this is something you all learned in CS 101.
- piaste 10y agoYou know how GOTO is real bad? Well, using exceptions for flow control* is basically a thinly disguised GOTO. Also, constructing an exception object, with the full stacktrace etc., is a pretty heavy operation and can cause big performance issues. But it's mostly the first thing. * Which is an important distinction. Flow control exception are recognisable because you intentionally throw an exception and expect it to be caught by a particular catcher to process it in a particular way - much like a GOTO, and with all its fragility. In the proper usage of exceptions, when you throw an exception you don't care which line of code catches it and when you catch an exception you don't care which line of code threw it.
- nerdponx 10y agoBelieve it or not, I was just working on a script this weekend that was becoming a nightmare to debug. And when I realized that I had been lazily using exceptions as control flow, this really hit home.