So I'm working on this code base, and every single method is contained within a try-catch block, which just logs the exception to a logging file.
I'm considering waving my hands around and trying to get this changed, but I'm gone in a month, and I'm not sure how much it really slows the code down. Yeah, it's horrible practice, but that's par for the course. Yeah, it makes errors more difficult to debug, but it's "easier".
The deciding factor for people here is speed. So I'm wondering how much slower would this really make the code? I'm asking for a ballpark estimation from someone who knows compilers much better than I do.
I know there's a lot of duplicate questions about whether or not exceptions slow things down, and that it differs depending on compiler versions and the like, but I'm looking for more of a factor of/ some advice here. I'm also just plain curious.
It's probably not going to slow down the running application, since it doesn't actually do anything until an exception is thrown. (Unless you're really trying to squeeze every bit of performance, and most applications don't need to do that. Not to mention that this coding style implies very heavily that this application probably has lots of other more prevalent problems.)
What it is doing is polluting the code with tons of unnecessary exception catching. (Note the difference between catching and meaningfully handling. I can guarantee you that this code is doing the former, not the latter.) It's slowing down development, and hours of developer time is a lot more expensive than milliseconds of system time.
Yeah, it's horrible practice, but that's par for the course.
Sounds like you've already left :)
Yeah, it makes errors more difficult to debug, but it's "easier".
Those are two mutually-exclusive statements. It can't be both more difficult and easier. Someone somewhere thought it would be easier. They were mistaken.
How much would wrapping every method in try-catch blocks slow a program down?
Measured in development time, a lot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With