|
bouyancy posted:I stumbled across this at work a while back. Somebody decided to be clever and make a data structure that could read any value from a bunch of different tables and queries. The setRow method is called on each row returned from a query. And they wonder why the appliction runs slowly. The punishment should fit the crime. Throw three hundred baseballs at him, and then tell him that's how the computer feels after running that code.
|
# ? Mar 31, 2009 11:51 |
|
|
# ? May 13, 2024 23:47 |
|
Zemyla posted:So if the result set is invalid, it throws and catches three hundred exceptions? Exactly but what is worse is that in Java the ResultSet throws an exception if you try to read from a column that wasn't selected in the query. So if you use this on a query that only selects a couple columns then it will throw and catch about three hundred exceptions for each row returned.
|
# ? Mar 31, 2009 16:36 |
|
bouyancy posted:Exactly but what is worse is that in Java the ResultSet throws an exception if you try to read from a column that wasn't selected in the query. So if you use this on a query that only selects a couple columns then it will throw and catch about three hundred exceptions for each row returned.
|
# ? Apr 1, 2009 16:26 |
|
BigRedDot posted:That is some sloppy laziness right there. Seriously, with some hard work and dedication you ought to be able to improve that number to over nine thousand exceptions per row! Come on, get to it! I really shouldn't have...
|
# ? Apr 1, 2009 18:42 |
|
A friend just told me about a guy he works with who prefaces every function name with his user name, as in:code:
|
# ? Apr 2, 2009 20:29 |
|
mr_jim posted:A friend just told me about a guy he works with who prefaces every function name with his user name, as in: code ownership baby
|
# ? Apr 2, 2009 20:58 |
|
my function is more optimized than your function, good thing we namespaced them, use mine
|
# ? Apr 2, 2009 21:55 |
|
That's great when you want to call a function you have to remember who wrote it. Then you know who to blame when it fails.
|
# ? Apr 2, 2009 23:17 |
|
mr_jim posted:A friend just told me about a guy he works with who prefaces every function name with his user name, as in: maybe he just saw all those examples using myFunc and decided to personalize it a bit further
|
# ? Apr 2, 2009 23:17 |
|
Spell posted:That's great when you want to call a function you have to remember who wrote it. Then you know who to blame when it fails. I told my friend that it was so he'd know who to punch in the face for not knowing about the "blame" feature of most SCMs.
|
# ? Apr 2, 2009 23:29 |
|
code:
But also: The flag is defined and manipulated, but never tested, in device.c. It is declared extern and tested, but never manipulated, in driver.c.
|
# ? Apr 8, 2009 11:03 |
|
Wheany posted:But also:
|
# ? Apr 8, 2009 11:13 |
|
TSDK posted:Why would you think this is a coding horror? Sure, it's a bit of an old-school way to get a status from a module, but then you are working in C. Well, it doesn't really show from those lines, but there is no need for the flag to even exist in device.c. It pretty much goes like this: code:
|
# ? Apr 8, 2009 11:41 |
|
I'm in an AI group, writing an agent that can solve Minesweeper in Python.code:
ih8ualot fucked around with this message at 18:45 on Apr 8, 2009 |
# ? Apr 8, 2009 15:10 |
|
Wheany posted:Well, it doesn't really show from those lines, but there is no need for the flag to even exist in device.c. That's still not much of a horror; it just looks like useless cruft that's accumulated over many revisions. To contribute, I just came across some code I wrote 6 months ago.... code:
|
# ? Apr 8, 2009 19:53 |
|
lol you work at Epic Systems.
|
# ? Apr 8, 2009 20:18 |
|
Todays' WTF moment, looking at some PHP login validation code written by a now long-gone coworker:code:
|
# ? Apr 8, 2009 20:28 |
|
Haha, I'm not sure what the bigger WTF is, the fact that you store the user/pass unencrypted in the cookie (thus sending it over the wire every time you request a page) or the blatant SQL injection.
|
# ? Apr 8, 2009 20:38 |
|
Ryouga Inverse posted:Haha, I'm not sure what the bigger WTF is, the fact that you store the user/pass unencrypted in the cookie (thus sending it over the wire every time you request a page) or the blatant SQL injection. Or that we don't even CHECK the password, don't forget that.
|
# ? Apr 8, 2009 20:40 |
|
dagard posted:Or that we don't even CHECK the password, don't forget that. THAT, and also that your 'permissions' are stored in a client side cookie.
|
# ? Apr 8, 2009 22:35 |
|
dagard posted:Or that we don't even CHECK the password, don't forget that. If the password is incorrect, won't it fail to connect to the database? It looks like the open_db() procedure uses the auth parameters in POST to connect
|
# ? Apr 8, 2009 23:19 |
|
Janin posted:If the password is incorrect, won't it fail to connect to the database? It looks like the open_db() procedure uses the auth parameters in POST to connect Nah.
|
# ? Apr 8, 2009 23:25 |
|
I keep finding this idiom lying around:code:
|
# ? Apr 9, 2009 02:12 |
|
GrumpyDoctor posted:I keep finding this idiom lying around: If it weren't for the fact that you're setting to NULL twice, this is completely acceptable and is in fact a recommended thing to do. (Though putting the error handling in the catch statement would be even better.)
|
# ? Apr 9, 2009 02:17 |
|
code:
code:
Beardless Woman fucked around with this message at 07:27 on Apr 9, 2009 |
# ? Apr 9, 2009 07:20 |
|
Beardless Woman posted:
Ah yes, that ancient coding blasphemy. Death to the not operator! All hail empty code blocks! Allah ackbar!
|
# ? Apr 9, 2009 16:09 |
|
code:
Simple, but effective.
|
# ? Apr 9, 2009 16:33 |
|
Avenging Dentist posted:If it weren't for the fact that you're setting to NULL twice, this is completely acceptable and is in fact a recommended thing to do. (Though putting the error handling in the catch statement would be even better.)
|
# ? Apr 9, 2009 17:14 |
|
pokeyman posted:Ah yes, that ancient coding blasphemy. Death to the not operator! All hail empty code blocks! Allah ackbar! He's using Perl (or Ruby) too, so he doesn't even have to use the not operator - unless will work just as well.
|
# ? Apr 9, 2009 18:28 |
|
pokeyman posted:Ah yes, that ancient coding blasphemy. Death to the not operator! All hail empty code blocks! Allah ackbar! Apparently "holder place" is the new "placeholder".
|
# ? Apr 9, 2009 20:13 |
|
Lexical Unit posted:Wouldn't LocalPlace* plp = new (std::nothrow) LocalPlace; be recommended over that code though? Seeing as all they seem to want to do is to set the pointer to NULL if new fails... Also, couldn't the catch (...) be masking any exceptions that LocalPlace's constructor might throw? You can do it however you want. It's not a coding horror to check for memory allocation failure. Worst-case scenario, it's slightly more verbose than necessary.
|
# ? Apr 9, 2009 21:12 |
|
Beardless Woman posted:
Hahahaha, I hadn't seen the first one, that's awesome. What the hell is reverse logic? Using !~ instead?
|
# ? Apr 9, 2009 22:23 |
|
Kidane posted:Hahahaha, I hadn't seen the first one, that's awesome. What the hell is reverse logic? Using !~ instead? In C I'd wrap the whole thing in () and put !(...)
|
# ? Apr 9, 2009 23:56 |
|
Kidane posted:Hahahaha, I hadn't seen the first one, that's awesome. What the hell is reverse logic? Using !~ instead? Yeah, or unless, as Ryouga said: code:
|
# ? Apr 10, 2009 00:21 |
|
code:
|
# ? Apr 10, 2009 15:45 |
|
wrok posted:
LOL, where the hell did you see that?
|
# ? Apr 10, 2009 21:00 |
|
MEAT TREAT posted:LOL, where the hell did you see that? It's pretty common in Python code written by people used to C++/Java.
|
# ? Apr 10, 2009 21:10 |
|
Janin posted:It's pretty common in Python code written by people used to C++/Java. [citation needed]
|
# ? Apr 10, 2009 21:25 |
|
Janin posted:It's pretty common in lovely Python code written by people used to C++/Java. I hope that provides some clarification.
|
# ? Apr 11, 2009 02:30 |
|
|
# ? May 13, 2024 23:47 |
|
evilneanderthal posted:I hope that provides some clarification. I've seen my share of lovely Python code and I've never seen that, sorry.
|
# ? Apr 11, 2009 06:38 |