Easy date canonicalisation



  • I just found this in a JSP page which I wrote a while ago. I think I was in a rush at the time, and it worked:


    startDate = dateFormat.parse(dateFormat.format(startDate)); // FIXME: This is stupid, but it makes the date fields at the bottom of the report match up with the dates used in the query.

    It's still there... 



  •  I'm glad to see that I'm not the only one who uses the // FIXME comment notation :) 



  • I'm glad to see that I'm not the only one who never fixes the // FIXME comments :)



  • @rbowes said:

    I'm glad to see that I'm not the only one who never fixes the // FIXME comments :)
     

    // TODO probably only when hell freezes over 



  • @rbowes said:

    I'm glad to see that I'm not the only one who never fixes the // FIXME comments :)

     

    I usually follow-up on //FIXMEs, but almost never on //TODOs.  And then there's the middle ground: //TODO: Fix me



  •  Something that impressed me with Eclipse was it automatically recognising all these comments in the code and giving me a tasklist of them. Y'know, in case I have a spare decade kicking around.



  • I use README as a placeholder for code not yet written (uncommented if the program absolutely shouldn't run until it is; it's an interpreted language, so this works).  "To do" is generally used at the entire-task level.

     

    I have a small handful of commented READMEs that still haven't been addressed, but only because the event being planned for (e.g. "if they add a second active warehouse" or "when division 2's operations move off of the old software") isn't happening any time soon, and possibly never will.

     



  • Found this the other day:

    // Uncomment this code for next release to replace switch clause below it - PhD 6/5/99

    //  if (!TranslateBuySellIndicator(record->stBuySell, BLIMRecord->OgBlockDetail.cTransaction))
    //  {
    //    sprintf(cMsg, "Unrecognised activity type value %d",
    //    record->stBuySell);
    //    OgRaiseTradeException(record, cMsg, EXCTYPE_INVALID_DATA_FIELD);
    //  }

    At this point, I'm just going to go ahead and leave it commented



  • The Real WTF is of course a developer signing with "PhD"...



  • I think the real WTF is that the statement "OgRaise" is not "OgSmash" as it should be.



  • In Xcode 3.0 on the Mac, it will add any comment that starts with:

    // TODO
    // FIXME
    // !!!
    // ???

    to the function popups. So you can see them in the order they appear in the file. (You may also be able to alphabetize them - I'm not sure. I don't use that option.) There's a configuration file where you can add or remove them, too. It's pretty useful.



  • @rhowe said:

     Something that impressed me with Eclipse was it automatically recognising all these comments in the code and giving me a tasklist of them. Y'know, in case I have a spare decade kicking around.

     

    Visual Studio also does this.



  • @vt_mruhlin said:

    Found this the other day:

    // Uncomment this code for next release to replace switch clause below it - PhD 6/5/99

    //  if (!TranslateBuySellIndicator(record->stBuySell, BLIMRecord->OgBlockDetail.cTransaction))
    //  {
    //    sprintf(cMsg, "Unrecognised activity type value %d",
    //    record->stBuySell);
    //    OgRaiseTradeException(record, cMsg, EXCTYPE_INVALID_DATA_FIELD);
    //  }

    At this point, I'm just going to go ahead and leave it commented

     

    // TODO:  Start using bugzilla.



  • @rhowe said:


    startDate = dateFormat.parse(dateFormat.format(startDate)); // FIXME: This is stupid, but it makes the date fields at the bottom of the report match up with the dates used in the query.

     

    What exactly is going on in this code.  I know the Java Data/Time stuff is a huge WTF in and of itself but what exactly is this thing intended to do?  You're taking a Date, turning it into a String, and then turning it back into a Date again using the same DateFormat object.  How does this alter the Date object? 



  •  I think you might need the definition of dateFormat for it to make sense:

    private static java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("d/M/yy");

    I'm pretty sure that it could be replaced with some java.util.Calendar fiddling to zero out the fields which are smaller than a day, but I've got bigger fish to fry, and nobody else here would even understand how to go about it, so it can stay there for now (probably for all eternity). 



  •  @dextron said:

    I think the real WTF is that the statement "OgRaise" is not "OgSmash" as it should be.

    QFT. 



  • OK, I see what you're doing there but I still don't get it.  I mean, presumably you're using a DateFormat when you're creating the report.  Couldn't you just leave it to the DateFormat to ignore the hours and minutes?

    Obviously it's your code so it's your decision either way but the very fact that you had to make a 2nd post to explain this one to me (with me being an average developer) means that someone else on your team (or your replacement) is probably going to have the same problem understanding this.  At the very least you could leave a comment like // stripping hours, minutes, seconds instead of the one that's there now.


Log in to reply
 

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