Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 2
    More a side-note than an answer, so written as comment: If you are planning a significant overhaul, then you should with priority fix the lack of communicating failure. If BigMethod doesn't successfully complete its job, it just writes something into a log, but there's no way for the caller to know about success or failure. The original author probably didn't embrace that exceptions were invented exactly for that purpose, as a means to communicate failure to the caller. So, I'd recommend to generally not catch exceptions, or at least to re-throw in a catch block. Commented Oct 24, 2023 at 7:06
  • 3
    Logging is a very basic feature you should be able to rely on. Not sure it's worth trying every time. Email exceptions could be caught higher up the call stack in a catch-all clause. Commented Oct 24, 2023 at 7:12
  • I've been watching the log output produced from this method for a while, the middle catch is probably safe to remove, so long as I double-check there's a higher catch up the stack. My concern was more that it might cause unexpected behavior in one of the callers up the stack. Thanks. Commented Oct 24, 2023 at 16:30
  • 2
    ... of bullet points that describe the high-level operation ("do this, do that", but in terms of the logic flow, not in terms of manipulating variables and calling libraries and frameworks). From there, you can figure out what to do next, cause now you have an overview of the overall structure. See which of those calls actually require the try block. Look for methods that look the same or almost the same and try to DRY them up. Extract some of those methods into separate special-purpose, narrowly focused classes if that helps you to shorten and simplify the code, or even delete some of it. 2/2 Commented Oct 24, 2023 at 20:42
  • 1
    This reminds me of the 1000-line do-loop that I inherited 25 years ago. Commented Oct 25, 2023 at 3:42