- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I would have called them "non-handlers", since they just immediately re-throw the thing they caught, without doing anything with it.
Admin
This is another project operating under the lines of code metric.
Admin
Gotta at least give them credit for rethrowing them correctly. "throw ex" destroys the stack trace (resets it to the new location). A plain "throw" statement preserves that stack trace.
Admin
Maybe they didn't know about "throw ex"
Admin
Usually these looks like debugging code (i.e. breakpoint fodder) but here there is nothing to debug.
Admin
doing nothing and kicking all problems down the line? this must have been coded by a manager.
Admin
Don't throw your ex.
Admin
Unless she is shorter than 147 cm at which point it becomes a sport.
Admin
Smells to me like a function stub, possibly generated from a template or something, but nobody ever bothered to fill in the details.
Admin
That led. The past tense (and past participle) of lead is led.
Admin
So find every place that calls it, delete the calls, then delete the method. EZPZ.
Admin
Obviously another case of a paid-by-the-line contract.
Admin
Typical case of "paid by line of code" ?
Addendum 2023-11-29 17:43: Looks like nearly everyone here had the same thought lol
Admin
In a serious note, creating exception scope is both under windows and linux expensive even if you don't throw an exception (which is super expensive). And for legacy reason the compiler will only remove completely empty exception handlers, as soon as you have any meaningful code like this assignment, you literally have the most expensive assignment that does nothing. Okay, maybe there's way to make it speed up global warming even more, but technically there's never a limit.
Admin
Thanks for illuminating that topic!
Admin
Is it possible the compiler will see that the variable is assigned to, but never used, and that the assignment can't possibly raise an exception? Not that I'm an advocate for letting monkeys bash at their keyboards and hoping the compiler will be clever enough to fix their nonsense for them.
Admin
Obviously done by someone that was still learning to write code. In-house training maybe. The "guru" told them to always return a value and to remember to handle exceptions. As for the "not doing anything" part, I think that's a good thing. Nothing gets broken.
Admin
Even better, delete the method, and see if it all builds and tests correctly (assuming they have unit tests). Chances are nothing is even calling that method.
Admin
I wanted to speculate, that maybe it overrides something and is needed to be there at least as an empty method. Then I saw³ that is a
private
method.Even without unit tests, it should be safe to remove the function.
Admin
So much "it depends"
Admin
Before you delete the calls, make sure you call each one when fields are filled and see if not clearing any fields is a bug.