|
I've got two PL/SQL ones that I found recently. First, I found this:code:
Also, this gem was found by a coworker and while it doesn't look terrible, it led to a ridiculous bug: code:
Of course, since userid can't be found in the table, and it wasn't explicitly referenced as users.userid, Oracle is helpful and assumes you mean the lexically scoped delete_user.userid, turning that condition into WHERE delete_users.userid = delete_users.userid. So we've set is_deleted on every single user! And then it loving commits! Jesus gently caress people, do not ever put commit in your procedure. npe fucked around with this message at 21:52 on Mar 21, 2008 |
# ¿ Mar 21, 2008 20:54 |
|
|
# ¿ Apr 30, 2024 01:53 |
|
tef posted:This do? Is there a das keyboard version?
|
# ¿ Mar 31, 2008 18:28 |
|
quote:Then you're no friend of mine. There's a difference between being concise and golfing (which Perl folk love to do) and this isn't golfing. The entire field of computer science has been about a power versus concision payoff. And if you can't see that, then you're hopeless. You guys are arguing about inelegant code, which can be annoying if there's a lot of it sure, but I have a hard time calling it really a "code horror", unless you're the type of person that gets in a huff about everyone's bike shed. For me, true code horror is when you realize that the author clearly doesn't have any idea whatsoever that what they are doing is terribly dangerous and evil (see my COMMIT in stored procedures rant from earlier), or just so outright incompetent that it's obvious the author doesn't really "get" programming in any way, like in the following (apologies for recycling this from the last thread, it's just too drat hilarious to me): code:
|
# ¿ Apr 1, 2008 15:11 |
|
poo poo, if I can get a few people to sleepily stare at my code for a few seconds during a code review, that's a good day.
|
# ¿ Apr 9, 2008 23:40 |
|
Some of the old perl code I've found here was written by someone who seemed to think entire subroutines had to be on a single line. Lots ofcode:
|
# ¿ Apr 12, 2008 23:41 |
|
Sometimes I think that if CoC had it's own YCS/helldump/BYOB style subforum, many people would have a hell of a time telling the difference.
|
# ¿ Apr 25, 2008 20:24 |
|
npe fucked around with this message at 01:52 on Apr 26, 2008 |
# ¿ Apr 26, 2008 01:49 |
|
|
# ¿ Apr 27, 2008 03:12 |
|
Today's horror is that I'm still arguing with people about why you can't delimit a file with literal 0xFE bytes when you want the delimited data to contain utf8 multibyte characters. A couple of people have now actually said "...but I thought all bytes were valid utf8?"
|
# ¿ Jun 14, 2008 03:12 |
|
I should have clarified, the file has to be a valid "text" file in single encoding. While you could delimit the data like that, it would be mixed encoding and would piss off text editors. In other words, the 0xFE bytes are tripping complaints from programs reading them about that byte not being valid utf8, and this is where the wtf complaints come from... "I thought anything could be unicode". npe fucked around with this message at 13:59 on Jun 14, 2008 |
# ¿ Jun 14, 2008 13:36 |
|
geetee posted:It only got worse after I emailed him my reply. Here's more bullshit: You know, I'm not going to defend this guy or what he's doing, but I think I've seen this solution before from people who want to simulate Oracle style sequences. Usually though, it's wrapped up in a single procedure to sort of hide the unpleasantness of it. I guess maybe I'm too used to Oracle, where out of the box we regularly have to query out of a one column, one row table to get certain types of queries to work.
|
# ¿ Dec 10, 2008 03:54 |
|
Iniluki posted:
By itself, that's not a "coding horror". In fact, it's necessary for lots of legitimate queries. Whether or not this particular query is terrible in other ways, I have no idea.
|
# ¿ Jan 19, 2009 13:26 |
|
code:
|
# ¿ Nov 9, 2009 16:10 |
|
Clearly there needs to be an IRegistrationInputSource which requires methods getName and getRoom. The Register class should be able to take an object that implements this and use it to obtain the information. A ScannerInputSource class can then be implemented that manages the use of the scanner, but future implementations can be developed and the correct one can be chosen at runtime.
|
# ¿ Apr 15, 2010 20:43 |
|
Found this bit of java code to left pad a number with zeros...code:
|
# ¿ May 31, 2010 03:59 |
|
HFX posted:It could be a bug, but would be very likely in a pre 1.5 environment. I was unaware of the format on String until you mentioned it. Now, I feel terrible for some places where I used while loops on String buffers to pad them. No, this guy is just crazy, this is all recent code (within the last year) and we regularly use StringUtils (which has a leftPad() function) all over the place. He also likes to pack multiple variables into a single comma separated string so it can later be picked apart via substring() to get at the relevant parts. This is to "work around" java's lack of multiple return values as he puts it.
|
# ¿ Jun 1, 2010 18:18 |
|
HFX posted:Couldn't he just use a list to do the same thing, thereby forming a tuple? His response to all of these types of questions is "this works pretty well." He's crazy. I just try to keep him away from anything I'll have to work on.
|
# ¿ Jun 1, 2010 18:49 |
|
Structs are nice for their non-nullability as well, which helps with ensuring correctness (or at least pushing the incorrect code around to where it should be).
|
# ¿ Jun 2, 2010 02:08 |
|
Dear Penthouse: I never thought it would happen to me. For years, I've been reading sordid tales of the "for case" paradigm, but I never thought they actually happened! But today, I found this in svn... quote:Changeset 19314 for AutomatedUser code:
code:
code:
code:
|
# ¿ Nov 18, 2010 17:12 |
|
baquerd posted:I'm not familiar with VB, but is the solution to store a pointer to the objects in an array I assume? Everything in there is 100% pure insanity. There is no fix. If you must think about it, though, just know that most of the current code in there can be replaced with a few dozen lines of code that uses ThreadPool.QueueUserWorkItem() and follows some of the ideas in http://msdn.microsoft.com/en-us/library/ms973903.aspx But we are way past that. Fuckin' arrays, how do they work?!
|
# ¿ Nov 19, 2010 02:08 |
|
Coming up next in the Coding Horrors thread, after the break: tabs v spaces brace styles toilet paper under/over
|
# ¿ Nov 20, 2010 02:44 |
|
code:
|
# ¿ Nov 23, 2010 18:48 |
|
Bozart posted:Someone made this at work in response to the insane requests people made of him: I've also seen "Bug: Square Peg does not fit into Round Hole", which exists solely so that tickets can be closed as a duplicate of it....
|
# ¿ Dec 8, 2010 14:14 |
|
quote:This is the fatal mistake made by frameworks like Spring XML, as well. As awful as Java can be, it is not improved by replacement with XML. These "configuration" files are always deployed along with the application and are never changed at run time. They dictate the wiring and behaviours of code and are rarely anything other than a representation of a shorter Java program. These configuration files are, in other words, code, albeit code with little to no compile-time checking and a more verbose syntax. This needed to be said. Shipping "configuration" files that your application code depends on being a certain way just to function is common horror that I don't think is called out enough.
|
# ¿ Feb 16, 2011 20:26 |
|
tabchat should be in YOSPOS, post more code horrors Today, I stumbled across this line. It made me curious, and I now regret my curiosity. code:
code:
code:
code:
code:
code:
|
# ¿ Aug 5, 2011 22:29 |
|
I... am not sure what's going on here. But it's funny!code:
|
# ¿ Aug 8, 2011 16:09 |
|
Well hello there thread, how ya been.code:
|
# ¿ Oct 27, 2011 01:32 |
|
Zombywuf posted:Here's the report boss, it comes with data in something that isn't Excel. What's that? I'm fired?
|
# ¿ Oct 29, 2011 15:34 |
|
code:
|
# ¿ Nov 22, 2011 16:54 |
|
If we're just tossing out blanket statements for all applications out of our rear end, then I'll use this opportunity to say your application shouldn't be concocting *any* queries on the fly ever - not even via an ORM. Use stored procedures and marshal your complex types. Keep the SQL in the db! (If this is not appealing to you then you should be using a document store and not a relational database anyhow.) *Note: I don't actually believe this. As it turns out, many application domains are completely different from each other and there are very different considerations for each!
|
# ¿ Dec 10, 2011 02:48 |
|
Kim Jong III posted:I've seen this in practice. I wasn't seriously advocating that it be used everywhere (like, it would be stupid for a web app). However, it can be very appropriate if you are already committed to a significant amount of application logic residing in the database to begin with (which is true for applications that rely heavily on certain Oracle components, for example). At my current job we do it and it's very easy, since I'm able to treat the database as just another callable component just like any other library. The implementation of the table structures is completely hidden from me, and whenever there's some whack-rear end restructuring of things, my changes (if any) are reduced to contract changes in the API.
|
# ¿ Dec 10, 2011 02:59 |
|
code:
|
# ¿ Dec 19, 2011 03:00 |
|
Well while I'm at it, I should post this one that's in literally every method I can see:code:
|
# ¿ Dec 19, 2011 06:33 |
|
Dessert Rose posted:If it's an extension method then it won't throw on null - you can call extension methods on null. This is probably the horror. You guys are way overthinking this. It's java, it's broken, and this paradigm is everywhere you look in this codebase (complete with matching catch (Exception e) { throw new Exception(e); } every time).
|
# ¿ Dec 20, 2011 01:40 |
|
Carthag posted:You can do the same thing in perl if you don't use strict;, and it's a really bad idea that makes code unmaintainable. With use strict your code fails due to the "b" in your values, but that's hardly fair because the discussion was barewords in keys, and this indeed works just fine with strict: code:
|
# ¿ Feb 14, 2012 03:23 |
|
Found this ticket lurking in an old pile of tickets opened by an ex-employee (that she had created and then assigned to herself). They are all great, but this one may be the best.quote:Ticket #7111 (new Enhancement (Functional))
|
# ¿ Mar 5, 2012 16:43 |
|
It's also why no normal human being would ever call the character set on a column a "constraint". A constraint in database terms implies a requirement that is actually enforced. If you take a stream of multibyte utf8 data and jam it into an ISO-8859-1 column, you end up with one of two things: if the client tried to convert from utf8 to the target character set, you will get dropped characters (the infamous "question marks in my data"). If the client jams the bytes in there as if they were the target encoding, then you get actual garbage from misrepresented bytes (as McGlockenshire describes). It's really hard to imagine a scenario where you'd want anything other than UTF8. You get 8 bits per character for the ASCII range (code points < 128) and proper support for everything else. There is literally no argument for using 7 bit ASCII, and only really bad arguments for using any legacy 8 bit encoding (involving handwaving about 3rd party applications that can't be changed). I can't fathom how you'd construe any of this as being a "constraint" by any sensible definition of that word.
|
# ¿ Jun 13, 2012 20:29 |
|
It's like anything, whether it's music, or movies, or literature. Agreeing on what is good is impossible. Agreeing on what is terrible is way easier.
|
# ¿ Jun 15, 2012 18:08 |
|
I can vouch for how at least how one major US bank works... transfers were done via what amounted to timed FTP jobs of text files which listed each transaction. These transfers frequently failed and had to be restarted, involving manual effort to rerun the transactions that hadn't processed yet. Naturally, this was a 24x7 department of people to monitor these jobs (which ran 5 times daily, as I remember) and repair them when they failed. As you can imagine, double transactions or missed transactions were not uncommon...
|
# ¿ Jun 21, 2012 22:41 |
|
|
# ¿ Apr 30, 2024 01:53 |
|
Zamujasa posted:I might be misreading this, but it looks like an infinite recursion, since if you give it a value of "EXAMPLE" it will try to return the result of IsNullOrEmpty("EXAMPLE".Trim()) (essentially, the same function call), which will call itself again and so on and so forth. No because I assume the class is named something like StringUtil, so it will resolve to the right call (String.IsNullOrEmpty() vs StringUtil.IsNullOrEmpty()). That's a perfectly useful utility function for 3.5, and don't assume that everyone was able to port their 3.5 codebase to 4.0 the day it was released. At worst, it was written in 4.0 by someone who wasn't aware of the new addition of IsNullOrWhitespace().
|
# ¿ Sep 11, 2012 21:17 |