General flags



  • In our continuing struggle supporting an existing application our employer acquired, we continually run into bizarre things. There's just so much wrong with this:

        /**
         * General flags. This helps to keep track of some problems and statuses of the program:
         * 0 - Cannot write to log, storing log into file.
         * 1 - Cannot write to backup file, losing log records.
         */
        private static char[ ] flags = new char[ ] { '0', '0' };
     
     
    mod: fixéd les brackettes –dh


  • (The missing close-brackets are the compose form's fault, for whatever reason.)



  • So... there are two logs that you're keeping track of, which were originally going to be written to a database with failover to a file, and you want to keep track of whether logging is happening to the database, to the file, or not at all. And for some reason somebody decided to do this in an array rather than separate named variables for each log file (but didn't put the other log file information into the same array). But then it got changed so that you're just logging to a file and the description wasn't updated correctly.

    At least, that's the sanest explanation I could come up with. If you assume the description is correct you get a whole new level of WTF, starting with "why is there no status code for normal operation?".



  • @Scarlet Manuka said:

    ...And for some reason somebody decided to do this in an array...

    ... yeah, they put booleans coded as numbers coded as chars in a char array. Essentially, they made true=49 and false=48. I'm pretty sure the zero and one in the comment are array indexes, not values, so normal would be both flags off. The whole thing does nothing but double-obfuscate the information it is storing.



  • @Jaime said:

    ... yeah, they put booleans coded as numbers coded as chars in a char array. Essentially, they made true=49 and false=48. I'm pretty sure the zero and one in the comment are array indexes, not values, so normal would be both flags off. The whole thing does nothing but double-obfuscate the information it is storing.

    Yes. True/false are represented by '0'/'1' characters and the 0/1 in the comments are positions into the array. Those "flags" would properly be individual Boolean fields...if it was at all necessary. If anything looked at those flags in the past, nothing does now; they're currently write-only.

    The logging in this application is a mix of hand-rolled filesystem logging, inserts into a database table with backup rolling of those to the filesystem, and immediate emails. However, the criteria for determining which one of these methods is used is practically Byzantine. Filesystem log entries don't contain a timestamp and often include supporting information (like a stack trace) for an error message sent through one of the other channels, so there's no way to tie anything together except circumstantially.

    All of this conspires to make the logging pretty much useless if you're trying to do detailed troubleshooting. It's really only been useful in its original state as a volume indicator: when error volumes are unusually high, something is going wrong.

    And by "unusually high", I mean that error emails go from 100-1000s per day to almost half a million. That particular condition occurs when a user enters a trans-ASCII character on the website.



  • @Thuktun said:

    If anything looked at those flags in the past, nothing does now; they're currently write-only.
     

    OK, my Java# is a bit rusty, but doesn't "static" mean "const" in this context?

     

     


  • ♿ (Parody)

    @Mason Wheeler said:

    @Thuktun said:
    If anything looked at those flags in the past, nothing does now; they're currently write-only.

    OK, my Java# is a bit rusty, but doesn't "static" mean "const" in this context?

    Exactly! The problem is really that the log file is a supercooled liquid, and with that many lines it will get thicker at the bottom.



  • @Mason Wheeler said:

    OK, my Java# is a bit rusty, but doesn't "static" mean "const" in this context?

    What?


  • @boomzilla said:

    @Mason Wheeler said:
    @Thuktun said:
    If anything looked at those flags in the past, nothing does now; they're currently write-only.

    OK, my Java# is a bit rusty, but doesn't "static" mean "const" in this context?

    Exactly! The problem is really that the log file is a supercooled liquid, and with that many lines it will get thicker at the bottom.

    Unless you change the value of index 0.999...



  • @Mason Wheeler said:

    OK, my Java# is a bit rusty, but doesn't "static" mean "const" in this context?

    Um, no. Java 'static' on a field means class-level rather than instance-level. Final is probably what you're thinking of.


  • ♿ (Parody)

    @morbiuswilters said:

    @boomzilla said:
    @Mason Wheeler said:
    @Thuktun said:
    If anything looked at those flags in the past, nothing does now; they're currently write-only.

    OK, my Java# is a bit rusty, but doesn't "static" mean "const" in this context?

    Exactly! The problem is really that the log file is a supercooled liquid, and with that many lines it will get thicker at the bottom.

    Unless you change the value of index 0.999...

    There must be a vaguely relevant yet controversially funny webcomic with minimalist art about all of this...



  • @boomzilla said:

    @morbiuswilters said:
    @boomzilla said:
    @Mason Wheeler said:
    @Thuktun said:
    If anything looked at those flags in the past, nothing does now; they're currently write-only.

    OK, my Java# is a bit rusty, but doesn't "static" mean "const" in this context?

    Exactly! The problem is really that the log file is a supercooled liquid, and with that many lines it will get thicker at the bottom.

    Unless you change the value of index 0.999...

    There must be a vaguely relevant yet controversially funny webcomic with minimalist art about all of this...


  • Trolleybus Mechanic

    @morbiuswilters said:

    @boomzilla said:

    There must be a vaguely relevant yet controversially funny webcomic with minimalist art about all of this...

     

     

    Mods, please change all cdxk comics to pictures of Rosanne Barr.

     



  • @Lorne Kates said:

    Mods, please change all cdxk comics to pictures of Rosanne Barr.


    [cough] … I thought that Morbs is a mod. here, or am I wrong?



  • @Cad Delworth said:

    @Lorne Kates said:
    Mods, please change all cdxk comics to pictures of Rosanne Barr.


    [cough] … I thought that Morbs is a mod. here, or am I wrong?

    Nope, just a mild-mannered forum regular. I could never hope to be a dashing Übermensch like ShadowMod.

    I thought Lorne was a mod, though.



  • I don't think anybody's a mod.



  • No *I* am Spartacus!



  • @blakeyrat said:

    I don't think anybody's a mod.

    ShadowMod is.



  • @Thuktun said:

    @Mason Wheeler said:

    OK, my Java# is a bit rusty, but doesn't "static" mean "const" in this context?

    Um, no. Java 'static' on a field means class-level rather than instance-level. Final is probably what you're thinking of.

    <pedant>
    You kinda need both static and final to make something a true constant in Java. Otherwise, with static-only, you have a value that can be changed, but the value is 'global' to all instances of that class (and if it is also public, changeable and readable by anyone). With final-only, you have an instance-variable which is read-only and there are (theoretically--I'm not sure what various JVMs are supposed to do with it) multiple copies of that value -- one per instantiation.
    </pedant>

     



  • @morbiuswilters said:

    @blakeyrat said:
    I don't think anybody's a mod.

    ShadowMod is.

    I don't think they exist. I will bow before him and lick his jackboots clean! Hail ShadowMod! Glory to his mighty modstaff!

    [FTFY. -ShadowMod]



  • @blakeyrat said:

    @morbiuswilters said:
    @blakeyrat said:
    I don't think anybody's a mod.

    ShadowMod is.

    I don't think they exist.

    This post makes me happy.



  • @blakeyrat said:

    Glory to his mighty modstaff!

    Gross, dude.


  • Way to ruin my joke.



  • @blakeyrat said:

    Way to ruin my joke.

    What was the joke?

     

    Unrelated:



    [RTFY. -ShadowMod]



  • @blakeyrat said:

    Glory to his mighty modstaff!

    Is the modstaff of unusual size?



  • @barrabus said:

    @blakeyrat said:
    Glory to his mighty modstaff!

    Is the modstaff of unusual size?

    It is of mod-est size.



  • @morbiuswilters said:

    @barrabus said:
    @blakeyrat said:
    Glory to his mighty modstaff!
    Is the modstaff of unusual size?
    It is of mod-est size.
    As long as it is not spasmodic.


  • Discourse touched me in a no-no place

    @Anketam said:

    @morbiuswilters said:

    @barrabus said:
    @blakeyrat said:
    Glory to his mighty modstaff!
    Is the modstaff of unusual size?
    It is of mod-est size.
    As long as it is not spasmodic.

    It appears to be episodic. And ShadowMod seem to have found even more roseworthy pictures than I've found thus far...



  • @boomzilla said:

    @morbiuswilters said:
    @boomzilla said:
    @Mason Wheeler said:
    @Thuktun said:
    If anything looked at those flags in the past, nothing does now; they're currently write-only.

    OK, my Java# is a bit rusty, but doesn't "static" mean "const" in this context?

    Exactly! The problem is really that the log file is a supercooled liquid, and with that many lines it will get thicker at the bottom.

    Unless you change the value of index 0.999...

    There must be a vaguely relevant yet controversially funny webcomic with minimalist art about all of this...


    Filed under: no doubt I'll learn about some other obscure webcomic I've never heard about before that uses stick figures

    [url=http://comicjk.com/comic.php/44]Comic JK[/url]?


  • ♿ (Parody)

    @Strolskon said:

    @boomzilla said:
    There must be a vaguely relevant yet controversially funny webcomic with minimalist art about all of this...


    Filed under: no doubt I'll learn about some other obscure webcomic I've never heard about before that uses stick figures

    Comic JK?

    Wow. I think the way they do comments really makes that site something special.


Log in to reply