Why must they taunt me so much from the past?



  • try {
    // do some stuff that doesn't explicity throw exceptions
    // call other stuff which doesn't claim to throw exceptions in the API contract
    container = getStuff();
    }
    catch (RuntimeException e) {
    throw e;
    }
    catch (Exception e) {
    this.logger.finest("error retrieving <stuff>" + ", setting container to null");
    container = null;
    }

    So, allow RuntimeExceptions to throw as normal, but trap any other Exceptions? Clever.



  • I seem to be missing the WTF..



  • @morbiuswilters said:

    I seem to be missing the WTF..

    That code can be replaced by "container = getStuff()"

     

    edit:

    To explain a little more: Runtime Exceptions are any exceptions that aren't declared.  Anything that gets to the catch(Exception) part must then be declared in the API.  But there are no exceptions that are declared, so that can be removed.  The only thing remaining is to just rethrow the exception, so it can be removed.



  • @Sutherlands said:

    @morbiuswilters said:

    I seem to be missing the WTF..

    That code can be replaced by "container = getStuff()"

    Fixed your typo, I see. And, yes, I understand that. However, there may have been checked exceptions in the past? Or maybe it's a safeguard in case any are added? That doesn't seem WTFy to me.



  • @morbiuswilters said:

    @Sutherlands said:

    @morbiuswilters said:

    I seem to be missing the WTF..

    That code can be replaced by "container = getStuff()"

    Fixed your typo, I see. And, yes, I understand that. However, there may have been checked exceptions in the past? Or maybe it's a safeguard in case any are added? That doesn't seem WTFy to me.
    I already fixed it! Hah!  Also added an edit, but you seem to know that part.  Anyway, yeah, those are valid.  This one for me is kind of *shrug*

    edit: I thought you were saying you fixed my typo.  Yes, I fixed my typo.

    Hah!



  • Because they still haven't figured out a way to taunt you from the future, that's why.



  • @TGV said:

    Because they still haven't figured out a way to taunt you from the future, that's why.

    Are you kidding? If his coworkers are anything like what I imagine, he spends his days cursing the WTFs they have planned.



  • @zelmak said:

    So, allow RuntimeExceptions to throw as normal, but trap any other Exceptions? Clever.
     

    That is indeed clever, as it is the way RuntimeExceptions are supposed to be treated in many cases.

     



  • @morbiuswilters said:

    @Sutherlands said:

    @morbiuswilters said:

    I seem to be missing the WTF..

    That code can be replaced by "container = getStuff()"

    Fixed your typo, I see. And, yes, I understand that. However, there may have been checked exceptions in the past? Or maybe it's a safeguard in case any are added? That doesn't seem WTFy to me.

    Yes, this is the reason.

    I guess not knowing a bit more of the backstory ... essentially, no one deletes code. They comment it out or create if statements with constants to jump around 'undesirable' code instead of removing it.

    "In case we might need it again."

    We ARE using a VCS ... we have backups of that VCS ... so saving code ... and I'm talking about figuratively thousands of lines of commented out or unreachable code ... just in case.

    Again, one of the things I'm trying to break programmers of doing ... let the VCS do its job. If you screw up a file, you can go back and look at how it was before you screwed it up.

    Perhaps comment out during development/developmental testing; but when you say you're done with you dev test, remove the detritus and submit.

    :shrug:

     

    Edit: forgot the quote



  • @Netdiver said:

    @zelmak said:

    So, allow RuntimeExceptions to throw as normal, but trap any other Exceptions? Clever.
     

    That is indeed clever, as it is the way RuntimeExceptions are supposed to be treated in many cases.

     

    The article doesn't say that at all.



  • @zelmak said:

    @morbiuswilters said:

    @Sutherlands said:

    @morbiuswilters said:

    I seem to be missing the WTF..

    That code can be replaced by "container = getStuff()"

    Fixed your typo, I see. And, yes, I understand that. However, there may have been checked exceptions in the past? Or maybe it's a safeguard in case any are added? That doesn't seem WTFy to me.

    Yes, this is the reason.

    I guess not knowing a bit more of the backstory ... essentially, no one deletes code. They comment it out or create if statements with constants to jump around 'undesirable' code instead of removing it.

    "In case we might need it again."

    We ARE using a VCS ... we have backups of that VCS ... so saving code ... and I'm talking about figuratively thousands of lines of commented out or unreachable code ... just in case.

    Again, one of the things I'm trying to break programmers of doing ... let the VCS do its job. If you screw up a file, you can go back and look at how it was before you screwed it up.

    Perhaps comment out during development/developmental testing; but when you say you're done with you dev test, remove the detritus and submit.

    :shrug:

     

    Edit: forgot the quote

    That is a WTF (although, unfortunately, an all-too-common one). Remember: context for you OP is important.



  • @zelmak said:

    I guess not knowing a bit more of the backstory ... essentially, no one deletes code. They comment it out or create if statements with constants to jump around 'undesirable' code instead of removing it.

    "In case we might need it again."

    Yeah, that's a WTF indeed. Well not if you want to make your code as unreadable and difficult to maintain as possible, then you're right on track! 

    As a rule of thumb, there should be no "green" code anywhere (comments obviously should stay).  This would make diffing code a nightmare: imagine all those lines of (maybe) commented out code where there is no text highlighting showing that it's a comment or live code (think /* */ vs. //). Yikes, I feel sorry for you...



  • @morbiuswilters said:

    That is a WTF (although, unfortunately, an all-too-common one). Remember: context for you OP is important.

    I'll try not to post in anger/frustration again ... but we all know that it will happen again.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.