• (nodebb)

    A means of setting a breakpoint on one of the return conditions using just simple static breakpoints..... Removing it would not "Break" operations, but would eliminate a potentially useful debugging/diagnostic point.

  • dpm (unregistered) in reply to TheCPUWizard

    You can't set a breakpoint on a line of non-code, so your guess is impossible.

  • Industrial Automation Engineer (unregistered)

    one line of code might have been scrubbed: // TODO

  • TrayKnots (unregistered)

    BatchProcessor.ProcessBatch() sure sounds like it triggers a side effect...

  • Kell S (unregistered)

    First iteration will be adding an "Intentionally left blank" comment in each branch.

  • MaxiTB (unregistered)

    Looks like someone forgot the throw new NotImplementedException() line in both branches.

  • Anonymous') OR 1=1; DROP TABLE wtf; -- (unregistered)

    Maybe they got a compiler warning that "return value from ProcessBatch() is unused", so they "fixed" it by doing this.

  • Barry Margolin (github) in reply to Anonymous') OR 1=1; DROP TABLE wtf; --

    That explains the if, it doesn't explain the else.

  • (nodebb) in reply to dpm

    That depends on the language. This is possible in C#, but I'm not sure about other languages.

  • cschneid (unregistered)

    Template inserted by IDE.

  • (nodebb) in reply to Kell S

    First iteration will be adding an "Intentionally left blank" comment in each branch.

    I pretty much have to do that because of a SonarQube rule we have turned on. If you have an "if/elseif" construct, SQ says it's a code smell if you don't have a final "else".

  • (nodebb)

    At the risk of not being snarky enough, my guess is that either: a) there used to be code in there that was rendered obsolete so it got removed, but the programmer didn't want to risk removing the if/else; or 2) the programmer was expecting a meaningful distinction, which then never materialized.

    Either way, @TrayKnots may be right, there may be a side effect of that .ProcessBatch() method. Of course, it could instead be simply assigned to a dummy variable (hopefully with comments to that effect) so that it happens, but avoiding the useless If.

  • (nodebb)

    Another possibility: The programmer wrote it but didn't know what to do in the failure case. His request for clarification went unanswered.

  • DrPepper (unregistered)

    <quote>everyone is just hesitant to touch something that works and they don't understand.</quote>

    Absolutely. If you change the code, then it needs to be edited, compiled and re-deployed. Something in that process might break; and thus YOU caused the system to fail. Whereas, if you make no change at all, it can't be your fault if something breaks.

    If it works, don't fix it.

  • cellocgw (unregistered)

    Easy: the code in the if and else clauses is written in Whitespace

  • (nodebb) in reply to dcon

    If you have an "if/elseif" construct, SQ says it's a code smell if you don't have a final "else".

    I like the lisp concept of (when COND BODY ...). It allows to make it clear that there is no else. In such a language, an if without else is indeed a code smell.

    More generally though?

  • MaxiTB (unregistered) in reply to Mr. TA

    Technically you can't set a break point on a line without code in C# (or any .net language) as well, but you can set them at the end of a scope (which is pretty much what { } mean in C like languages), because scope ends are usually also injected with break statements (in .net they are nop's, natively it depends on the platform). And in release compilation often code is eliminated (as are empty branches already by the IL compiler, long before NGEN finally gets rid of them in case of using [Conditional] for example), so you can't really properly debug non-debug code for that simple reason. Same also is true for C/C++, there's just no IL compiler, because you already compile natively. And most other languages behave in a similar way, most can have break points at the end of a scope.

  • MaxiTB (unregistered) in reply to Barry Margolin

    I was working with clients in the past where some style guides demanded an else statement for every if statement. It doesn't make sense obviously, bloats the code unreasonably, but well, usually there were else branches with comments, just to shut up StyleCop.

  • (nodebb) in reply to Mr. TA

    Can do it in Javascript and Java too.

    Rather useful at times I must say.

  • (nodebb)

    My bet is that he refactored a bunch of ugly code out, piece by piece, and then just had to leave the empty conditional block behind as a symbolic monument to that work. Probably planned to pull it out soon afterwards and forgot.

  • Jeremy (unregistered) in reply to dcon

    Is an empty if or else block anot a code smell then.

    Writing code like thIs to satisfy code quality tools certainly is smelly. If you dont understand why a rule exists you should either learn why or remove the rule.

  • Your Name (unregistered)

    So? Remove the if. Obviously nothing changes if you do.

    You might want to check inside the function if it does some error handling though.

  • MaxiTB (unregistered) in reply to TrayKnots

    Actually it does. If this is actually a.method meant to be called incrementally, the bool could indicate an idle state which would be useful for further handling following request of pause processing for a while ;-)

  • (nodebb) in reply to MaxiTB

    @MaxiTB - Thanks... especially with debug versions of some "C" compilers I have seen for mainframe applications (not totally out of the question for a financial application)

  • Farokh (unregistered)

    Many years ago I was working on C code using Microsoft's C compiler for a DOS based program. I spent a long time trying to figure out a bug in the program. The issue was that if I put a debugging statement in the code, the code would work. I took out the line and the code would fail. I finally looked at the machine language that was being generated and the code was wrong. So, I called Microsoft (this was before the days of email) and tried to get support on it. I even went so far as to create a tiny app, (source code and makefile) that would trigger the error. I released my code with a simple zz=x+1; which was s do nothing line and everything worked fine. Got a letter back from Microsoft stating they couldn't reproduce the error I was claiming. Not long after I got an update disk for the compiler and poof, bug was fixed.

  • Strahd Ivarius (unregistered)
    Comment held for moderation.
  • uoonik (unregistered)
    Comment held for moderation.
  • Kordalia (unregistered)
    Comment held for moderation.
  • Modular Kitchen & Wardrobe in Raipur Chhattisgarh (unregistered)
    Comment held for moderation.

Leave a comment on “The Bad Batch”

Log In or post as a guest

Replying to comment #:

« Return to Article