- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
i did not see "prepare statement" statement between "sqlquery.append" and "parameters.put"
Admin
Aha, I get it: so TRWTF is calling the parameter to these methods "original", amirite?
Admin
CopyPasta is delicious served with a side of WTF sauce.
Admin
I ran across this in our db recently. App called sproc 1 with a parameter x.
sproc 1 said, "if x = a, call sproc 2, else call sproc 3"
sprocs 2 and 3 used the exact same query, except 2 hard-coded some value v1 and 3 used v2.
Sigh.
Admin
Admin
MAPPINGS is a "database" table! Thanks to qualify it like that - now I can rest assure that you did not mean a picnic table or a kitchen table.
Admin
I suppose it might have been a wooden table.
Admin
This IS the Daily WTF, so it could have been a gigantic hardcoded table embedded right in the code instead of in the database - we've seen it before. And then of course they'd search it with an O(n^2) algorithm...
It soon becomes obvious it is a database table, but explicitly calling it 'database table' up front works well here for establishing that that isn't the WTF at least.
Admin
Not related to the WTF, but I would use different "string wrapper classes" or typedefs to explicitly encode that those 2 different identifiers (which happen to be strings) are different and cannot be mixed up. The purpose of type systems is to model the domain space and to express the programmer's intent.
Admin
Many (too many) programmers I work with do not have a good grasp on what their intent even is.
And im fairly certain that no programmer whose code ends up here know what they are doing & how to do it. Otherwise, the code would not have ended up here.
Admin
Queen to d1? Pawn to f3 check?
Admin
logger.debug(" Query bbdd" + sbQuery.toString());
Apparently teh BBDD is a Spanish plural form of "database".
Admin
That might've been an attempt to prevent problems with parameter sniffing. I expect by now things have improved, but a few version of sql server ago, that could've been a reasonable way to ensure that each version used an appropriate execution plan. More likely it was just bad code, but it is at least plausible.
Admin
It could have been excel, never forget excel
Admin
In my opinion, it's not necessarily wrong to have a separate method for each category. Otherwise anyone who wants to do a query has to know the correct category name to use, and the code becomes harder to read. In a well-organised project, you might also have different category queries in different modules, possibly with different access specifiers.
However, I would do this by writing one method that takes the category as a parameter and does the actual query, then have a one-line wrapper method for each category that passes a hardcoded category name to the actual query method.
Admin
I think it's done inside the
accessBdNonXa.lookup(sbQuery.toString(), parameters)
function. Hopefully they use the proper parametrisation functions of their database API and don't do some exploit-filled string substitution/concatenation/escaping nonsense.Admin
I think the reason for the
StringBuffer
for a single line is that older JVM implementations of the "+" operator used an implementation that was slower than making your ownStringBuffer
and appending it withappend()
instead. Or they are just bad and/or inattentive programmers...Admin
I found an example of what I'm talking about: https://www.appmarq.com/public/security,7196,Avoid-large-number-of-String-concatenation