• hello (unregistered)

    first

  • Jonathan (unregistered)

    We have a joke on out team, whoever uses the blame tool only ever finds out that they were the one who committed the bad code.

  • TheCPUWizard (unregistered)

    Technically the last one is not a "Fail".... The resultant value will be globally unique and can be used as an identifier, even though it does not conform to the 128 bit number format...

  • Bert (unregistered)

    The first one looks more like a bit of a brain fart. Perhaps the block previously had other bits in too, which were later deleted and only the assert remained.

    I've also done/seen Assert.True(false) in the absence of Assert.Fail() or in an "impossible" arm of a large match block.

  • Bert (unregistered) in reply to Bert

    And then here's me not reading the title or even the first paragraph.

  • Todd (unregistered)

    TRWTF is that they mention the function generateUUID(), but then post the function generateGUID().

  • posedge clock (unregistered) in reply to Bert

    I've written code like the first one only last week! Mine was of the form:

    if (!foo()) {
        assert(foo);
    }
    

    The idea here is to put a breakpoint on the assert, which allows you to step into foo() only if it is known to fail.

  • European swallow (unregistered) in reply to posedge clock

    If only modern IDEs allowed you to set conditional breakpoints...

  • Carl Witthoft (google)

    So, what's the opposite of 'cerebral flatulence'? 'sigmoid colonic cogitation'?

  • Karl Bielefeldt (github) in reply to European swallow

    Conditional breakpoints are orders of magnitude slower than an if statement. If you're going to hit it a lot, sometimes you have no choice but to alter the code, or your timing gets corrupted to the point of being unusable, especially on embedded systems.

  • Lazerbaems (unregistered)

    My first thought on the last one is that the developer responsible didn't trust that UUIDs are actually UUIDs and so they added this clever "guarantee" part at the end of it.

  • Fnord (unregistered) in reply to Carl Witthoft

    Sigmoid Colonic Cogitation = management

  • Verisimilidude (unregistered)

    Remy, where are the unicorns today?

  • Chris (unregistered) in reply to Jonathan

    So "he who smelt it, dealt it" applies to brain farts too?

  • Bert (unregistered) in reply to European swallow

    So you're using one of the half-dozen languages that has a full-featured bells-and-whistles IDE built specifically for it? Congratulations.

  • Geg (unregistered) in reply to posedge clock

    I don't know on what platform you're working, so this may not be available, but on macOS and windows there are calls to break into the debugger.

  • derp (unregistered)

    The last one isn't generating UUIDs, its generating GUIDs... And they seem to contain meatsack readable information, so I'd wager a guess that it's for ease of tracking down problems from log entries. And they are also still perfectly unique, but with added information. They also don't need to follow a UUID format, since it's not a UUID.

    I wouldn't quite count that as a brain fart on the side of the code author, but rather on the side of the code reader and blog post author.

  • Dave (unregistered)

    I am the guy that submitted the last one ... the code 'worked' but it was completely useless I just noticed it was showing up as a uuid column of our audit table (tracks event logs). That already has a unique id (primary key of the database) but this developer has this method to generate a uuid .. with this method that for some reason makes it 'more unique' by adding the server name (auditlog.getContext) and time. The Context and request time that is appended to this ... are already part of the auditLog data that gets persisted to the table ... it is just weird and redundant (the author user has many such entries in our code base)

  • Dave (unregistered)

    I am the guy that submitted the last one ... the code 'worked' but it was completely useless I just noticed it was showing up as a uuid column of our audit table (tracks event logs). That already has a unique id (primary key of the database) but this developer has this method to generate a uuid .. with this method that for some reason makes it 'more unique' by adding the server name (auditlog.getContext) and time. The Context and request time that is appended to this ... are already part of the auditLog data that gets persisted to the table ... it is just weird and redundant (the author user has many such entries in our code base)

Leave a comment on “Cerebral Flatulence”

Log In or post as a guest

Replying to comment #:

« Return to Article