• (cs)

    Visible -- When this Post is read it is Visible Hidden -- When this Post is read it is Hidden FIRST -- When this Post is read it is VeryFIRST

  • Sam Vimes (unregistered)

    That's Constable Carrot, thank you very much.

  • (cs)

    string sql = "exec spRequestInitechData '"

    • txtData.Text.ToString().Replace("'", "''") + "'";

    Sometimes, I can't imagine the thought processes that lead to the WTF. I think it may be scarier when I can.

    "We should escape the apostrophes when we build the SQL command, to prevent injection attacks." "Actually, I've heard that the accepted standard is to use stored procedures." "Oh. Hey, I've got an idea. Let's do both! Belt and suspenders, right?" "Brillant!"

  • WhoMe (unregistered)

    What exactly is wrong with this?

    $dir = 'test';
    if (!file_exists($dir) || !is_dir($dir))
    {
        exec('mkdir '.$dir);
    }

    Safe mode == exec. It's not ideal, but it works.

  • (cs) in reply to WhoMe
    WhoMe:
    What exactly is wrong with this?
    $dir = 'test';
    if (!file_exists($dir) || !is_dir($dir))
    {
        exec('mkdir '.$dir);
    }

    What, you mean aside from the fact that it's failing to use the mkdir() function?

  • Kendall (unregistered)

    Come on, even Excel has VeryHidden data. Nothing wrong with keeping the users out of the icky stuff.

  • Makkhdyn (unregistered)

    The "parseStringData()" method isn't that weird.

    "replace()" replaces (as its name states) a character with another, but here every '/' is removed; it's not quite the same thing as a replacement.

    Sure it could have been better, going through the "char[]" version of the "String" and putting every non '/' character into a "StringBuilder" is way more efficient than using "split()" (which is a regex), but still, it isn't that bad.

  • Makkhdyn (unregistered) in reply to Makkhdyn

    PS: I assumed it was Java code.

  • kjordan (unregistered) in reply to Makkhdyn
    Makkhdyn:
    The "parseStringData()" method isn't that weird.

    "replace()" replaces (as its name states) a character with another, but here every '/' is removed; it's not quite the same thing as a replacement.

    Sure it could have been better, going through the "char[]" version of the "String" and putting every non '/' character into a "StringBuilder" is way more efficient than using "split()" (which is a regex), but still, it isn't that bad.

    But with replace() you can choose to use an empty string to replace with.

  • Don (unregistered)

    Actually, hidden/visible/veryhidden is probably akin to the Excel functionality for sheet visibility; when just hidden the sheet is there but you can get it back very easily using the unhide functionality. Veryhidden means it will only be unhidable by use of VBE or the immediate window (both of which you can lock down).

    I would imagine the functionality is looking to do something like that; in other words hidden just means from view but accessible through the GUI or app, with an option to unhide; while veryhidden means only code can unhide.

    Or maybe the function is part of an Excel library itself?

  • Programming 101 (unregistered)
    if (!file_exists($dir) || !is_dir($dir))
    if (!file_exists('test') || !is_dir('test'))
    if (!TRUE || !FALSE)
    if (FALSE || TRUE)
    if (TRUE)

    So if 'test' exists and is not a dir, a dir named 'test' will be created?

  • Makkhdyn (unregistered) in reply to kjordan

    Only since java 1.5, if you work with an old code (which can happen [really, it happens to me all the time]) this kind of "gem" can be found everywhere.

  • Nagesh (unregistered)

    When makeing directorys it must be avoideing the "horse race condition" that another user takes you directorie befor you used it. This bug cause hakker joy steel all data etc. Must use current time to create garenteed uneek directorie then rename to 'test' or watever name is reallee wanted. Sum language have function to do this alreadee. Any professional programmeer know this best practic.

  • (cs) in reply to Sam Vimes
    Sam Vimes:
    That's Constable Carrot, thank you very much.
    Constable Carrot of the Yard!?
  • doctor_of_common_sense (unregistered)

    meh. Seen a lot worse. Until the setting drop down category selection to "I Am Krogan" does something nefariously stupid, all these WTFs are nothing more than a coffee stain on a book in someone else's trash.

  • (cs)

    What's the problem with:

    public static int EvalToInteger(string statement) { string s = EvalToString(statement); return int.Parse(s.ToString()); }

    Note that the supplied string is named "statement"--I would assume EvalToString is doing some sort of evaluation, it doesn't just return what was passed in.

  • sadwings (unregistered) in reply to Nagesh
    Nagesh:
    When makeing directorys it must be avoideing the "horse race condition" that another user takes you directorie befor you used it. This bug cause hakker joy steel all data etc. Must use current time to create garenteed uneek directorie then rename to 'test' or watever name is reallee wanted. Sum language have function to do this alreadee. Any professional programmeer know this best practic.

    I miss TopC0der, but you are fun too.

  • Fred (unregistered)
    VeryHidden Very Hidden. When the item is serialized out as xml, its value is "veryHidden".
    Were it not for this line, the table could have been completely machine generated. But the three variations on "very hidden" suggest at least the possibility that some human drudge-drone was involved -- but not human enough to realize that an actual explanation might be useful.

    Anyway, why is it a table? Shouldn't it be XML?

  • Jack (unregistered) in reply to sadwings
    sadwings:
    Nagesh:
    When makeing directorys it must be avoideing the "horse race condition" that another user takes you directorie befor you used it. This bug cause hakker joy steel all data etc. Must use current time to create garenteed uneek directorie then rename to 'test' or watever name is reallee wanted. Sum language have function to do this alreadee. Any professional programmeer know this best practic.
    I miss TopC0der, but you are fun too.
    I'm operating on the assumption that they are the same person. After all, didn't Alex banish TopCod3r to India? (As a fate worse than death, it is the supreme punishment.)
  • Paul Neumann (unregistered)
    # Find the last 200 transactions logging.debug( "Finding the last 600 transactions" ) ConnMysql.query("select Id from Transactions order by ts desc limit 0,10000 ")

    This is quite obvious. The requirements changed. Everyone knows only green code needs to be commented. When changing existing code, the intent is already clear so updating the documentation is merely a work avoidance technique.

  • (cs) in reply to Loren Pechtel
    Loren Pechtel:
    What's the problem with:

    public static int EvalToInteger(string statement) { string s = EvalToString(statement); return int.Parse(s.ToString()); }

    Note that the supplied string is named "statement"--I would assume EvalToString is doing some sort of evaluation, it doesn't just return what was passed in.

    Maybe so, but s.ToString() is redundant, and what's left is simple enough that you might want to compact it into one line:

     return int.Parse(EvalToString(statement));
    

    Still, if your assumption is correct, then what's left is a relatively small WTF; on the same scale as BDate and EDate, where AFAICT the only WTF is that ToUpper() is unneeded.

  • (cs) in reply to Fred
    Fred:
    VeryHidden Very Hidden. When the item is serialized out as xml, its value is "veryHidden".
    Were it not for this line, the table could have been completely machine generated. But the three variations on "very hidden" suggest at least the possibility that some human drudge-drone was involved -- but not human enough to realize that an actual explanation might be useful.

    Anyway, why is it a table? Shouldn't it be XML?

    For robustness, you should print out the XML, photograph it on a wooden table...

  • (cs)

    I think the visibility enumeration needs a few more enumerations. These come to mind: Sort of Hidden, Cleverly Hidden, Poorly Hidden, Extra Hidden, Forever Hidden, Optimally Hidden, Resolutely Hidden, Nervously Hidden, Unbelievably Hidden.

  • Tom (unregistered)

    Whoever wrote that "EditTDemensions" function should be beaten.

  • (cs) in reply to Sam Vimes
    Sam Vimes (fake):
    That's Captain Carrot, thank you very much.
    FTFY
  • FragFrog (unregistered) in reply to Loren Pechtel
    Loren Pechtel:
    What's the problem with:

    public static int EvalToInteger(string statement) { string s = EvalToString(statement); return int.Parse(s.ToString()); }

    Note that the supplied string is named "statement"--I would assume EvalToString is doing some sort of evaluation, it doesn't just return what was passed in.

    If there are any sort of naming conventions there, EvalToString will convert something to a string, just like EvalToInteger converts something to an integer. So now you have a string, which is evalled as a string, and then its string value is parsed.

    That doesn't sound the least bit redundant to you?

    Mind you, now I am assuming that a string variable's value is equal to it's .ToString value. Would not surprise me much if there is some weird null condition where that is not the case.

  • Terry Pratchett (unregistered) in reply to Sam Vimes
    Sam Vimes:
    That's Constable Carrot, thank you very much.

    You need to catch up now. I am dying and you're still stuck on the constable part. Carrot was promoted to Captain several books ago.

  • (cs) in reply to FragFrog
    FangFrog:
    If there are any sort of naming conventions there, EvalToString will convert something to a string, just like EvalToInteger converts something to an integer. So now you have a string, which is evalled as a string, and then its string value is parsed.

    That doesn't sound the least bit redundant to you?

    I think the intended idea is that EvalToSTring will evaluate the statement and return the result as a string, just like EvalToInteger will evaluate the statement and return the result as an integer.

  • Paul Neumann (unregistered) in reply to FragFrog
    FragFrog:
    Loren Pechtel:
    What's the problem with:

    public static int EvalToInteger(string statement) { string s = EvalToString(statement); return int.Parse(s.ToString()); }

    Note that the supplied string is named "statement"--I would assume EvalToString is doing some sort of evaluation, it doesn't just return what was passed in.

    If there are any sort of naming conventions there, EvalToString will convert something to a string, just like EvalToInteger converts something to an integer. So now you have a string, which is evalled as a string, and then its string value is parsed.

    That doesn't sound the least bit redundant to you?

    Mind you, now I am assuming that a string variable's value is equal to it's .ToString value. Would not surprise me much if there is some weird null condition where that is not the case.

    However, your entire naming convention assumption is that EvalToInteger is the same as int.Parse. If EvalToString is not the same as .ToString(), then EvalToInteger cannot be the same as int.Parse and the naming convention is preserved. The reverse is also true (though admittedly redundant (my shop calls this a "friction layer")).

    Therefore you have presented us with a tautolgy and yet complain it is false.

  • AB (unregistered)

    [quote]"Like many fellow developers, the codebase I work on each day is terrible and devoid of any structure,"[quote]

    Hey, as a developer I may be terrible and devoid of any structure, but I resent being compared to that code.

  • Jay (unregistered)

    With no clue what EvalToString does, the only thing odd about the example is that he takes a toString of a string, which is pointless.

    Some posters seem to be assuming that EvalToString converts an integer to a string, so that then doing the parse just converts it back, making the function pointless. But this clearly can't be true, as the input parameter is not an integer but a string.

    I don't see a WTF here at all. They have some function that does we know not what to a string, and gets a result that is another string. In at least some cases, this result is, in fact, parsable as an integer, so they have a second function that calls the first, gets the result, and then parses it to an integer. This seems like plain good coding to me. What would be preferable, to make another function identical to EvalToString except that it returns an int? Duplicating who knows how much code?

  • Lone Marauder (unregistered)

    That last one reminds me of OSPF area types:

    Stubby Not So Stubby Totally Stubby Totally Not So Stubby

    I wish I were making this up...

  • Jay (unregistered)

    I'm really surprised that no one has pointed out the obvious error in the enum. Of course there should be FOUR values: Visible, Hidden, VeryHidden, and FileNotFound.

  • (cs)

    The "THIS SETTING SHOULD NOT BE 'TRUE'" WTF is classic. I can imagine this pattern is present in huge numbers of dodgy codebases. The "sort of 3(ish) value" "boolean". Hours of fun debugging & maintaining no doubt. The Visible/Hidden/VeryHidden one is the same as Windows Explorer's Visible/Hidden/Protected OS scheme, so a popular 'idea', though popularity is no guide to quality. Having just seen Jays post above, of course he's correct about 'file_not_found'

  • The Nerve (unregistered)

    The System.out one is easily fixed at a global level.

    public class SystemInfoLogger extends PrintWriter {
       Log log = LogFactory.getLog(SystemLogger.class);
    
       public void print(String val) {
         if (log.isInfoEnabled()) {
           log.info(val);
         }
       }
    
       // other overridden methods here
    }
    
    public static void main(String[] args) {
       System.setOut(new SystemInfoLogger());
       System.setErr(new SystemErrorLogger()); // left as an exercise to the reader...I can't do all you're thinking for you.
    }
  • (cs) in reply to emurphy
    emurphy:
    ... on the same scale as BDate and EDate, where AFAICT the only WTF is that ToUpper() is unneeded.
    Does DRY mean anything to you?
  • (cs) in reply to pjt33
    pjt33:
    Does DRY mean anything to you?

    I must admit I don't get it either. One is today's date, the other is tomorrow. Where does he repeat himself?

  • that guy (unregistered) in reply to pjt33

    The first one looks like a part of this code, probably not a WTF. http://odetocode.com/code/80.aspx

  • jmacpherson (unregistered)

    [I] [just] [don't] [see] [any] [problems] [with] [the] [classic] [ASP] [code] [.] [Where's] [the] [WTF] [?]

  • Alex Papadumbass (unregistered) in reply to jmacpherson
    jmacpherson:
    [I] [just] [don't] [see] [any] [problems] [with] [the] [classic] [ASP] [code] [.] [Where's] [the] [WTF] [?]

    STFU. I am the boss here and if I have published it, it is a WTF. Print your expert opinions on a toilet paper and shove it up your ass.

  • (cs) in reply to Jay
    Jay:
    I'm really surprised that no one has pointed out the obvious error in the enum. Of course there should be FOUR values: Visible, Hidden, VeryHidden, and FileNotFound.
    Wrong wrong wrong! Its an enum, not a BOOL. True, False, and File_not_found are the 2 BOOLEAN VALUES we can pick from. It has no place in enums.

    Although, if hidden well enough, may not be found...

  • Nagesh (unregistered) in reply to Alex Papadumbass
    Alex Papadumbass:
    jmacpherson:
    [I] [just] [don't] [see] [any] [problems] [with] [the] [classic] [ASP] [code] [.] [Where's] [the] [WTF] [?]

    STFU. I am the boss here and if I have published it, it is a WTF. Print your expert opinions on a toilet paper and shove it up your ass.

    I know what ass is (shown, left), but what is toilet papper?

    [image]
  • Nagesh (unregistered) in reply to Jack

    I am being re-encarnation, but not knowing my prevous identities.

  • Gary Olson (unregistered)
    Private CARROT() As Char = {"^"c}
    Carrots contain vitamin A, not vitamin C.
  • Not Nagesh Either (unregistered) in reply to Nagesh
    Nagesh:
    When makeing directorys it must be avoideing the "horse race condition" that another user takes you directorie befor you used it. This bug cause hakker joy steel all data etc. Must use current time to create garenteed uneek directorie then rename to 'test' or watever name is reallee wanted. Sum language have function to do this alreadee. Any professional programmeer know this best practic.

    You are very bad at being Nagesh. "hakker"? "Sum"? Seriously, don't do it again.

  • (cs) in reply to Nagesh
    Nagesh:
    Alex Papadumbass:
    jmacpherson:
    [I] [just] [don't] [see] [any] [problems] [with] [the] [classic] [ASP] [code] [.] [Where's] [the] [WTF] [?]

    STFU. I am the boss here and if I have published it, it is a WTF. Print your expert opinions on a toilet paper and shove it up your ass.

    I know what ass is (shown, left), but what is toilet papper?

    [image]
    And since we're on that topic... can we stop using the same 7 pictures of a 3rd world country over and over again everytime we want to demean the quality of work or people from india?
  • geoffrey, MCP, PMP (unregistered) in reply to FragFrog
    FragFrog:
    Loren Pechtel:
    What's the problem with:

    public static int EvalToInteger(string statement) { string s = EvalToString(statement); return int.Parse(s.ToString()); }

    Note that the supplied string is named "statement"--I would assume EvalToString is doing some sort of evaluation, it doesn't just return what was passed in.

    If there are any sort of naming conventions there, EvalToString will convert something to a string, just like EvalToInteger converts something to an integer. So now you have a string, which is evalled as a string, and then its string value is parsed.

    That doesn't sound the least bit redundant to you?

    Mind you, now I am assuming that a string variable's value is equal to it's .ToString value. Would not surprise me much if there is some weird null condition where that is not the case.

    EvalToString obviously has to do something besides pass through the parameter passed in as a return value. Otherwise, why even have it there? You make a dangerous assumption. I'm guessing that it does some sort of logical evaluation on the value passed in, so that int.Parse() does not receive a null value.

  • Richard (unregistered) in reply to PiisAWheeL
    PiisAWheeL:
    Nagesh:
    And since we're on that topic... can we stop using the same 7 pictures of a 3rd world country over and over again everytime we want to demean the quality of work or people from india?
    I don't know why you consider this picture demeaning. They have shoes (sorta) paved roads and even, it would appear, intermittent access to running water. Sounds like one of those Chamber of Commerce things trying to praise a place, not put it down.
  • (cs) in reply to Richard
    Richard:
    PiisAWheeL:
    And since we're on that topic... can we stop using the same 7 pictures of a 3rd world country over and over again everytime we want to demean the quality of work or people from india?
    I don't know why you consider this picture demeaning. They have shoes (sorta) paved roads and even, it would appear, intermittent access to running water. Sounds like one of those Chamber of Commerce things trying to praise a place, not put it down.
    I didn't consider the picture demeaning. Its context (fake nagesh using it with bad english and not saying anything funny) was designed to be demeaning. But that is not my point. There are like 7 of these pictures that get used in EVERY FUCKING THREAD! Its called the internet. Go find something a little more original and less worn out. That picture needs an arrow to the knee.
  • Mr.'; Drop Database -- (unregistered) in reply to Nagesh
    Nagesh:
    Alex Papadumbass:
    jmacpherson:
    [I] [just] [don't] [see] [any] [problems] [with] [the] [classic] [ASP] [code] [.] [Where's] [the] [WTF] [?]
    STFU. I am the boss here and if I have published it, it is a WTF. Print your expert opinions on a toilet paper and shove it up your ass.
    I know what ass is (shown, left), but what is toilet papper?
    It's that disgusting stuff they use in countries that aren't civilized enough to use bidets.

Leave a comment on “EvalToInteger, 'gumdrops', and More”

Log In or post as a guest

Replying to comment #378735:

« Return to Article