Sometimes you forget to



  •   Inspired by the recent self-wtf thread I figured I'd post something I stumbled on today in some of my old code:


    //Returns the number of consecutive backup failures recorded for this server from the very last entry (chronologically) to the last success.
    //Specifically it returns an array of ints that has two elements. The first shows how many
    public int[ ] getConsecutiveBackupFailures() {
            int[ ] functionResult=new int[3];
            functionResult[0]=0;    //Number of recorded (in the db) failures
            functionResult[1]=0;    //Number of consecutive days without a successfull confirmed backup
            functionResult[2]=0;    //1 if the server has reported a full tape, 0 otherwise



    I'm not sure what's more retarded, the comments or the fact that I return that array instead of storing the results in class vars and providing getter methods for them.



  •  Well, at least it's commented. Would you have liked this more?

    public int[] gCBF()
    {
        return new int[]{db.query("SELECT count(nF) FROM flrs").getInt(1), (int)db.query("SELECT NOW()-dt FROM flrs ORDER BY dt DESC LIMIT 1").getDate(1), (BSConn.gP("tpF")==true?1:0))};
    }
    


  • @DOA said:

    I'm not sure what's more retarded, the comments or the fact that I return that array instead of storing the results in class vars and providing getter methods for them.

    Well, it's quite obviously a case of


  • a case of null? what's that?



  • Reminds me of a little calendar application I was told to update when I first started working at my current job. It was a portlet/JSP app meant to pull data on events (conferences, seminars, etc.) from a database it shared with another app that allowed users to create and register for events, and then show them on the appropriate dates on a little calendar. The event data was passed around the calendar app as an array of Strings, usually called data[].

    data[0] was the title of the event, data[1] was the start date of the event (as a String with a two-digit year, e.g. "12/24/08"), data[2] was the end date (again, as a String), and data[3] indicated whether the event should show up on weekends on the calendar. It would be either null or the empty String (depending on where in the code it was constructed) for weekdays only, "*" for Saturdays, "**" for Sundays, and "***" for both Saturdays and Sundays. None of this was documented anywhere in comments, design documents, etc.



  • I've had a few cases of this. "Why isn't this function doing anything? ...oh, because I never actually wrote the function and just left an empty stub..."


Log in to reply