Software Developers who need to be kicked in the balls

The following software developers need a good swift kick in the balls:

  • People who can’t let a boolean stand alone, and have to compare it to another boolean, as in "if (isOffline() == true)“. Why not be extra safe, and make that “if ((isOffline() == true) == true)“?
  • People who don’t realize that after you’ve modified a value in a Map, you don’t need to re-add it back to the Map to have it take effect. “get” returns a pointer to the original object, not a clone of it.
  • Eclipse (or maybe Visual Age) users who leave the code littered with comments that say “ * TODO To change the template for this generated file go to Window - Preferences - Java - Code Generation - Code and Comments" or Insert method description. Either configure the template, or turn off automatically generated comments.
  • Anybody who declares a method to throw “Exception”, and anybody who calls methods that have explicit lists of what they throw, but who surround it with a “catch (Throwable t)” block. I don’t care if all you’re going to do is print the stack trace and continue, there’s no excuse for that sort of laziness.
  • Anybody who changes huge swathes of somebody else’s code without asking the original developer if there is a better way. Especially if it’s code I wrote just a few weeks ago.
  • People who use ‘do {…} while(cond);” People who use “if (cond == true) do { … } while (cond == true);” need to be kicked repeatedly.
  • The entire staff of my company’s China office.

11 thoughts on “Software Developers who need to be kicked in the balls”

  1. And women who do that kind of stuff deserve a kick in the balls, too, so what’s the issue?

  2. do { … } while(cond); is something I’ve almost never seen in 20+ years of C, C++, and Java. The very rarity of it means that it is a surprise when you see it – which means that you should only use it where you really need to run the loop once before testing the conditional. Putting the same damn condition before it, as in “if (cond) { do { … } while(cond);}”, which I’ve encountered about 10 times in the last two days while re-writing some code from a former co-worker, is just fucking stupid. What this guy has done is taken a very common and instantly recognizable and understandable paradigm, the “while” loop, and turned it into something nowhere near as comprehensible.

  3. “do { … } while(cond); is something I’ve almost never seen in 20+ years of C, C++, and Java.”

    Um, I’m just sitting here with my jaw dropping open. Application programming must be a wonderful and exotic land, because I see do/while all over the place in systems code. (And in places where I can’t see it being replaced except by either duplicating big chunks of code or putting a goto.)

  4. I can’t see anything wrong with the “do { … } while(cond)” construct, either. There are valid uses of it, such as when you need to execute the chunk of code at least once. If you’re using another means of getting achieving the same behaviour you’re probably making it too complicated.

    Of course, I suppose you could get the same effect by sticking a label at the top of the chunk of code and an if with a goto at the bottom. (But those people *should* be given a swift kick.)

  5. I come to you as a lay person with less than no understanding of what you’re talking about. And yet…

    Can I give Bill Gates a kick for Word?

    Yes, yes. Easy target. Yes, yes world philanthropy.

    Blah blah blah.

    Fucking facist defaults. Word is a writing program developed without any understanding of writers.

  6. I could be wrong here, but I thought evaluating the conditional before executing the ‘while’ is the way to do it.

    Paul, you’re not explicitly condemning do/while, are you?

    In Perl I’ll use
    while (conditon) {
    *do something*
    }

    but putting the *do something* first seems arse ways about for multiple reasons.

    JAFPH

  7. I’m not 100% down on do/while, although like I say they’re relatively rare in the sort of code I do. Yesterday, I was redoing somebody else’s code and I replaced at least 10 and possibly 15 “do/while” loops that had either a conditional at the front or a repeated chunk of code with much clearer “while” loops. Several of them turned into “for (FooClass fc : fooClassCollection) { … }” loops, and the others were mostly “while (resultSet.hasNext()) { … }” loops.

  8. I’d agree that putting a conditional before “do .. while” is pretty inane. But, like another commenter, I see it fairly often in the kind of code I peruse, much of which is very low-level device-driver kinds of stuff.

  9. To clarify, when I say “I see it”, I mean a plain-old do…while (without preceding if), used in the appropriate way (do something at least once).

    BTW, I completely agree about the folks who do “if (someBoolean == true) …”. AAAARRRGGGHHH!!!!

Comments are closed.