• Cornify (unregistered)

    I think these all make sense.

  • TheCPUWizard (unregistered)

    If only people had some sort of way of examining how code got to the point it is over a period of time....much might be revealed....

  • bvs23bkv33 (unregistered)

    the job of dev is not to write code, his job is to know exactly what mood was last dev in while writing the code currently on screen - maybe his wife left him? were his kids good at school? is his pet okay?

  • Noddy (unregistered)

    sometimes the new guy has to repair/patch/improve/change what the old guy did.... and in most of these cases the old guy built a boat when what he needed to build was a car.. with some serious effort you can perhaps convert a boat into something that resembles a car just to find out, after deployment, what the client actually want, is a plane.....

  • Oliver Jones (google)

    "Effects may proceed without cause."

    WTF? With respect, Remy, you're challenging Aristotle and Aquinas. What are you, some kind of heretic, overturning dogma handed down from the ancients?

    No?

    A 21st century programmer?

    Oh, righto. Forgive the interruption. Carry on. :-)

  • Karl Bielefeldt (github)

    We should all start adding Facebook style emotion messages to our version control logs:

    Fixed CN-43502 causing crash of system when empty string is entered for date. -- Feeling amused :-)

  • ApoY2k (unregistered) in reply to Karl Bielefeldt

    Not quite what you said, but close...

    https://github.com/sasstools/sass-lint/

  • Kaewberg (unregistered)

    str(date) will not correctly display january as "0", as our requirements apparently are saying

  • Friendly_Reminder (unregistered)

    I skimmed through some SQL-Queries buried deep in stored procedures and such. They all begin their where clause with

    "WHERE 1 > 0 AND [...]"

    The reason is, if you change that to say "WHERE 1=0" it's never true and the update or insert will not be executed. But it's still a head scratching moment when you see something like this for the first time. "What? On which occasion would 1>0 NOT be true?"

    Also, simply commenting out the unwanted statements seems to be too much hassle... or maybe it's just TOO obvious? Wouldn't it be funny to change a few of those statements to something like "WHERE 1 < 0" and then everyone could dive into the code trying to figure out what the hell wents wrong.

  • null null (unregistered) in reply to Friendly_Reminder

    I've seen this, but because each condition was "AND x=y" on its own line. You can move conditions around and un/comment them by line without having to make sure all the ANDs still line up. Much like comma-separated arguments with lines of ", argumentN" so that there isn't a dangling "," to mess things up.

  • I dunno LOL ¯\(°_o)/¯ (unregistered)

    At least for once, the WTF was not the choice of date format.

  • Friendly_Reminder (unregistered) in reply to null null

    By "commenting out the unwanted statements" I meant like, commenting out the entire insert or update statement, not simply change around one condition in the where clause. Forget to change it back and it can be a bitch to track down. Try skimming through dozens of SQL queries and try to spot the one query with "WHERE 1=0" instead of "WHERE 1>0". If the whole statement is commented out, it becomes obvious in an instand. Provided the tool you use offers syntax highlighting.

  • CRi (unregistered) in reply to Cornify

    How boy was I disappointed when I saw in the source that it was just your surname...

  • null null (unregistered) in reply to Friendly_Reminder

    Oh, right. Yeah, that sucks. I don't suppose the Resident Ninja comes out and says "well duh, that's my supreme coding standards"?

  • Jan Stroopwafel (unregistered) in reply to TheCPUWizard

    There is a way. It is called version control.

  • CRi (unregistered) in reply to Jan Stroopwafel

    Biggest whoosh ever! Congratulations ;-)

  • Carl Witthoft (google) in reply to Jan Stroopwafel

    But what system controls the version of the version control system?

  • jgh (unregistered)

    It's amazing how many people cannot manage to format a (UK) telephone number correctly, even though there are only three rules: 01nnx abcdef n!=1 else 02x abcdefgh else 0xxx abcdefg

  • Crunch Crumble Chomp (unregistered) in reply to Carl Witthoft

    A self-hosting version control system...the code for the version control system is hosted within a running copy of the version control system itself...

    ....now if you host the code for the main website for the version control system in a running copy of the version control, you've gone to the next level...

    ...and if you're running the main website for the version control system from a running copy of the version control...

    ...you've got the 'Fossil' source control system: https://www.fossil-scm.org/index.html/doc/trunk/www/index.wiki

  • Little Old Flat Earth Crank-job Lady (unregistered) in reply to Crunch Crumble Chomp

    It's version control systems all the way down. <smug>

  • I'm not a robot (unregistered) in reply to jgh

    Nope https://en.wikipedia.org/wiki/Telephone_numbers_in_the_United_Kingdom

  • Parametamolcil (unregistered)

    Still contemplating the edge cases for WHERE 1 > 0

  • Me, myself and I (unregistered) in reply to null null

    I hate hate hate lines starting with ','. It's so painful to read. Yet people think it's such a good idea that clang-format will do that for member initialisation lists and it is horrible (and it doesn't work very well if you happen to want to comment out the first initialiser).

  • (nodebb)

    I looked at our codebase, most of the worst was made by "Commit, Initial". I hate that guy.

  • weiping (unregistered)

    I swear I saw the last code block somewhere online as an answer to a syntax-related question, trying to show the various ways of converting date-time.

  • MiserableOldGit (unregistered)
    (and it doesn't work very well if you happen to want to comment out the first initialiser).

    Yeah, well my guess is that's what the "where 1>0 " is doing, so they can just go in and blindly comment out conditionals without fretting about the syntax. My first thought was that this is someone building the where clause using string concatenation elsewhere and didn't want to bother checking for the first/last condition to avoid an extra " and ". One mess hiding another.

    Either that or they are checking the space time-continuum is still functioning correctly, we wouldn't want to go spitting out misleading results if suddenly up=down or datediff(day, today, tomorrow)<0.

  • null null (unregistered) in reply to jgh

    01nn..., n != 1? That rules out many major cities. (Someone else has already linked you to the Wikipedia article)

    Also, the only formatting rules for tel numbers are that global numbers begin with +. Any other number is subject to routing/interpretation by exchanges, so you can't reasonably be expected to be able to know any number belongs to any region and then format it as such.

    It's much like email in that the best way to deal with it in all practical cases is to leave it as a plain text field.

  • Appalled (unregistered)

    WHERE 1>0 (I actually use WHERE 1=1, more obvious) is the oldest trick in the book for building dynamic queries. Once in place you can easily add 'AND so and so' where you're applying an unknown quantity of multiple Filters from a user screen.. The true beauty is that you never need to know or care how many Filters were actually requested, as it also covers the case where there are no filters at all (you don't need to check to check first and omit the WHERE when none). The presence of this construct in an SP simply means that the Filters were passed onward to an SP to do the work rather than the running dynamic SQL.

  • Nelson (unregistered) in reply to Me, myself and I

    My general thinking with styling is that I want to be able to quickly find relevant portions of the query/code, and I can do that if I try to ensure that everything is always in the same place.

    In a comma separated list, the line lengths are not predictable, but the beginning is. Thus, if the comma is at the beginning of the line, I know exactly where to look. It may not seem like much, but in my line of work (database engineer supporting BI platforms with databases older than me), I'm constantly parsing through SQL queries that are around 1,000 lines with hundreds of columns. If I can easily find where the definition of each column starts, my life is way easier (also why I prefer [alias] = value rather than value as [alias]). This is especially helpful when the results are complicated expressions that either go off to oblivion or span multiple lines.

    When it comes to aliasing a table, once again, the position of the end of the line is unpredictable, but the beginning is not. Thus, I put the alias on a new line. I also treat it as I do a variable in code and use a meaningful value for it. If the table is [Address] and I'm joining to it from a column like [WorkAddress], I'd alias it workAddr. I hate it when I see a table aliased as the first letter or so. When I'm using the value elsewhere, a.[Status] doesn't tell me nearly as much as workAddr.[Status]. In either case, if I'm still unsure about what the alias represents, I could go back to the join to see where it came from, and it's a hell of a lot harder to find the source if I can predictably find the alias at the beginning of its own line.

    Overall, I wish that people would appreciate whitespace in SQL like they do in other code. I'm not reading these queries like a novel, so don't write it like one. I just want to be able to look at an expression and be able to find where the data comes from.

  • Nelson (unregistered) in reply to Nelson

    Woops, the last sentence of the penultimate paragraph should be:

    In either case, if I'm still unsure about what the alias represents, I could go back to the join to see where it came from, and it's a hell of a lot easier to find the source if I can predictably find the alias at the beginning of its own line.

  • jan stroopwafel (unregistered) in reply to CRi

    yeah sarcasm, i know

  • Chance (unregistered)

    That last one might be even more awesome than explained.

    Does the format string passed to strptime mean you don't get leading zeros?

    But then they did the whole str() the different struct parts because they wanted them??

  • Howard (unregistered)

    I like this kind of CodeSOD. Lots of little, unrelated, anonymous WTFs. Y'all should do this regularly ... kinda like Error'd for code snippets. Good show.

  • BentFranklin (unregistered)

    Come for the fails, stay for the philosophy.

  • sf. (unregistered) in reply to Friendly_Reminder

    Commenting out the SQL will break the stored procedure. Compiler will barf an error about e.g. SQL code behind the stored procedure taking 0 parameters, 3 provided or something along these lines. The approach of if(false&...) makes the query no-op, but doesn't prevent the code from running, accepting all inputs, and returning properly formatted table of 0 rows.

  • medievalist (unregistered) in reply to TheCPUWizard

    In the 70s and 80s we had automatic file versioning in operating systems. Saved many millions of programmer hours... if that technology had matured, instead of being discarded, the arcane incantations of (relatively primitive) modern source control systems would be completely unnecessary.

    But sadly, although 64-bit computing has been rediscovered, automatic file versioning is gone, thanks to Dunning-Kruger and the Blub paradox. The only place is lingers in on CDs, in the sadly dated ISO9660 spec, and OSes generally make sure you can't see it even there.

Leave a comment on “The Story of Things”

Log In or post as a guest

Replying to comment #:

« Return to Article