• Ginssuart (unregistered)

    if(first) { if(first) { Console.WriteLine("Frist"); } }

  • (nodebb)

    Has the file been found, though?

  • (nodebb)

    Is this really C# code?

    FILE_LINK, file.itemId, file.name
    

    Every name is not following the convention here... how do people after 25 years still get it wrong.

  • Officer Johnny Holzkopf (unregistered)

    Is this your file, Larry? Is this your file, Larry? ... Is this your file, Larry? Is this yours, Larry? Is this your file, Larry? Is this your file, Larry? - Look, Larry, have you ever heard of string.Format? We know that this is your FILE_LINK, your file.itemId, and your file.name! And we know this is your file!

  • (nodebb)

    I love the break statement at the end of the if clause.

    I mean, it's not a loop. But we break out of the condition just to be sure that at the end of the clause, the cprocessor doesn't execute some undefined random code fragments because there was no bounds check.

  • (nodebb)

    My problem with this code is that it is destined for collisions: without a delimiter, and given the typical pattern of "last name, appended with first letter of first name", StartsWith(username) will eventually return a false positive for Mary Smith when the file actually belongs to John Smithmeyer.

  • (nodebb)

    StartsWith also takes the current culture into account

  • (nodebb)

    LGTM code review. Technically, it is a code review: there is a response, you did write a whole 4 letters.

  • Die Kuhe (kein roboter) (unregistered) in reply to Ginssuart

    if(this==first && first==this) // both must be true, if(this==first) // (the second check may have invalidated the first) if(first==this) // (or was it the other way round?) printf("first?"); // TO DO: check.

  • Registered (unregistered)
    Comment held for moderation.
  • (nodebb)

    The IDEs I use (PhpStorm, CLion) warns about "always true/false" conditions, so I think it would catch this.

    But I admit that when it warns about these kinds of things in old code I often don't do anything about it, to avoid cluttering up pull requests with unrelated and negligible changes.

  • Naomi (unregistered) in reply to MaxiTB
    Comment held for moderation.
  • OldCoder (unregistered) in reply to Barry Margolin

    My problem with this is not that it is trivial, but the author may have cut/pasted the code intending to change the second condition for something else but then become distracted, ie Boss, phone call, etc and forgotten to change the code.

    Alternatively, this could have been a much larger code block that has been chopped but not properly.

    Both ways, I think it would have deserved at least a mention at the code review.

  • (nodebb) in reply to Melissa U

    It might be inside a loop, though. Will C# allow a break statement that is not inside a loop? That might be TRWTF, I guess.

  • (nodebb)

    You guys all missed it: this code checks for file name permanence. It has to be correct, and it has to STAY correct thru the second "if" .

  • NotYourLocalJavaWizard (unregistered)

    At least it wasn't:

    if (check()) {
    if (reallyCheck()){
    }} // We just have to be sure!
    Console.WriteLine("Frist"); 
    

Leave a comment on “Double Checking”

Log In or post as a guest

Replying to comment #:

« Return to Article