- 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
At least it has more lines of code...
Admin
Who needs to filter data on the database side when you can filter in your application, I mean, think of all the flexibility you have.
There's a reason why 1gig of ram is so cheap and servers have terrabit connections!
</sarcasm>
Admin
This is ezactly how one shouldn't do things. Get everything. Throw it into an array. Use clever find methods that you wrote. Hey, a sql database is just like some sheets in excel.
Admin
wtf.... guess they never read the sql manual :#
Salandur
Admin
Everyone knows you don't put business logic at the database level, so I don't see the WTF here.
Admin
Maybe they read the "Sql injection" vulnerability stories and decided "well, we'll only run static string queries then"
Admin
Dude, please tell me my sarcasm meter is broken.
Admin
At least they're protected from SQL injection attacks, I guess.
Admin
It's either broken or there's been an overflow somewhere. :P
Admin
If you could just find a way to union all the tables together, you wouldn't really need the database anymore.
Admin
Oh yea.
WTF!?[:'(]
Admin
Um... what happens when you call getDetail() with a contactId on a ID that doesn't exist in the database? Infact, how did this thing even compile with only a conditional return being present?
Admin
Maybe they just recently converted the data layer from text files???
Admin
I paid for that bandwidth, dammitall, and I'm gonna use it!!!
Admin
Well, it wasn't slow when I tested it. Maybe your server just needs more memory.
Yes, I did test it with less than 100 records. Why do you ask...?
Admin
It's Damitol, and it's trademarked. (But covered by most drug plans.)
Admin
oh fer god's sake.
that's just ridiculous.
Admin
You can do this in SQL alone. We have a SQL statement that does:
SELECT * FROM (
--huge whopping pile of rows
)
WHERE ROWNUM BETWEEN 1 AND 200
Admin
First, I have to admit that on a RARE occasion, I do something kind of like that in C#. If I have a collection, that is ALREADY a subset of the data (Never the entire table--because I DO believe in WHERE clauses), and is relatively small (10-300 rows max) i might loop thru it rather than opening another connection to the database. This is because I already have all the data I need, I just need to pick out a row from the existing collection or check for the existence of a particular item. Its easier to code than creating another method to query in my data layer, another method in my business layer, etc. Maybe this is non-optimal, but I don't do it all the time. Feel free to berate me though... [:D]
Second, I had heard of a guy at one of my old jobs do something similar to this WTF. This guy supposedly had worked for microsoft, and supposedly has helped develop ASP classic, and was supposedly this awesome miracle worker programmer. Well, a colleague of mine at this job got a hold of his code while coming in contract to help with the same project, and the guy was getting all the records from one table, looping thru them using a recordset, then within each iteration, looping thru all the records in another table thru a second recordset, and matching the first table's Foreign key to the second table's primary key, so then he can display data from both tables on the same page...hey does that kinda sound like an INNER JOIN????
The "microsoft" guy was fired, and my colleague had to start the project over from scratch because all the code was that bad.
Admin
Idiots. Everyone knows it is much more effecient to run a select query in a loop and select one row at a time until you find the one you need (probably better to keep selecting until the last record though, because since there is no such thing as primary keys, there may be a newer record later on in the table).
Admin
your suttle sarcasm has me in utter despair that there would be more than one person who does not recognize the utter horror of the code. pls clarify your reasoning.[:|]
Admin
This way the guy can come back and solve the slow solution and get paid a bonus!
pretty smart.
Admin
There really is only one response to that level of utter fuckwittery .... in Ireland it would be three alpha-numeric characters P45 (the form your employer has to give you and the taxman at the end of your employment)
Admin
That is sarcasam right?
You'd be insane to suck ENTIRE tables into your application each time you want to suck out just a single record.
If you were serious I's LOVE to be the person you buy your servres off, I'd be loaded!
Bart.
Admin
I don't even know anymore.
Admin
Maybe record.getContactId() returns an instance of a class that has a method "equals(String)" which can not be expressed as a WHERE clause in SQL. It's hard to tell whether or not this is a WTF. ;-)
Admin
No.. you should suck in every database on the database server (if more than one), store each in an array, and use custom "search objects" that you coded during college to emulate the data access layer and pull out a single record.
BTW, I wanted to note this site has given me inspiration. I am currently hard at work on a javascript based database that uses cookies for it's storage.
Admin
Well, I .NET when you use a dataset, it does suck the entire SQL statement into memory on the local PC. So if you do a "Select * from blah" it will load up every thing that is in that table to the dataset. A dataset in .NET is really cool too! You can just say .writexml and bam, you have a bloated file with the dataset in it for future use! (In xml of course!)[:P][:D]
Admin
http://www.despair.com/incompetence.html
Admin
Hibernate?
Admin
Your problem is that you're too negative, Mr. Ian Boysenberries.
Admin
This WTF tastes like burning.
Admin
well it's still better than the wtf we had some weeks ago - where a very confused guy loaded the whole table into a textfile an compared each line with the search string....
Admin
When I started working at my first .Com job, our CTO (who started a very famous .com before this one) FORBID us to us joins! His reasons were database indepenancy which kinda was valid, since we had no database abstraction layer, since we had no concept of appliation layers in the code to begin with, all our SQL calls were hand writen into the code.
I will allso mention that he frown edon the use of methods since it was inefficient compared to inlining everything. But that's another story for another time.
Admin
<sarcasm>
The real WTF is that he probably has more than one table in his database. I mean really! Why split "contacts" off of say "orders"? After all, we all know that a single table to hold all of your data is much more efficient than having to do all those nasty joins, right?
</sarcasm>
Admin
DBs are pointless anyway. Perl, regexp and a single flat text file beat Oracle any day of the week in terms of maintainability, scalability, speed, and data integrity.
Joins are for people who can't write a good regexp.
<FONT size=1>(yes, I am kidding)</FONT>
Admin
There's also the generic version of the drug, it's called screwitol. There's also the extra strength version called fuckitol. :O)
Admin
Well... I suppose if the table is not indexed on ContactId... oh screw it, I can't defend this. WTF???
Admin
Actually, I know at least one programmer (TopMind of Ward's Wiki notoriety) who wants to do the opposite: replace all objects and containers with 'agile' in-memory relational databases. I swear to all the gods this is the truth. While some of what he says makes a lot of sense (especially about the cult of OO and the way programmers tend to take technical disagreements as personal attacks), most of it is pure lunacy.
Admin
Is that Damitol Red, Blue, or Yellow?
In any case, just go into your drug store, and say "Damitol!" They'll
know what to give you.
(FWIW, that's the first Congress Of Wonders reference I've seen on
the net in at least five years. Nice to know they're not entirely forgotten.)
Admin
hum, speaches are expensive now that sgeorgia raised the price of the sfruit.
-dZ.
Admin
How can a string not be expressed as a string, when a WHERE condition is just that... a string?
Looks like some dumdum Access "developer" that got thrown into an SQL project.
Admin
I love how he's declaring a new ResultRecord for each row in the table. (allocate more space on heap, read resultset var into it, compare, remove space from heap, repeat) Or would this not be a problem with todays compilers?
Admin
GetContacdId might concatenate 3 fields, subtract 42 from the result multiply it by blueberry pi's and then rijndael decrypt it. Try that in a where statement! [:P]
Drak
Admin
This is so bad I'm really feeling sick. I've worked with lots of say, less gifted programmers, over the years and finally moved to a position to keep away from them. Codes like this bring all bad memories back.
Admin
You seem to have forgotten that you can parameterize the query for your dataset. Only a moron always sucks up the whole table.
Admin
public class ResultRecord {
public MyContactId getContactId() {
return new MyContactId();
}
private class MyContactId {
public boolean equals (Object o) {
return (Math.random() > 0.314);
}
}
}
Admin
Well it was hard, but I finially came up with a logical explination:
They are not using a standard database, rather something written long ago, say on some 36bit machine (not 32!) and now running on an emulator. Back in those days they didn't know as much about algorithm analysis and didn't have to deal with very large datasets, so a O(n^2) algorithm in the where clause (which wasn't where at the time because SQL wasn't invented yet) worked just fine. As the company grew of course it no longer did, so they learned to do things this way. As time went on SQL was added as a project to be more buzzword compliant, but nobody was allowed to fix the database because it worked just fine even if it was slow.
So programers did thing this way because an O(n) search is much faster than the O(n^2) in the database. Of course if you needed lots of data over time from on query (and could assure the data wouldn't change in the meantime) many programers implimented a hash table, but when you just need one result from an unsorted list you can't beat this search.
Excuse me now, I think i'm gonna have to go cry...
Admin
I knew Ian Boysenberries, John Smallberries is no Ian Boysenberries.
Admin
Voyager: "There really is only one response to that level of utter fuckwittery .... in Ireland it would be three alpha-numeric characters P45 (the form your employer has to give you and the taxman at the end of your employment)"
And on the right side of the Irish Sea, too.
(I'm bemused that a P45 is a P45 in Ireland too. Presumably it predates the republic. Oh, and my regards to Maynooth - you have a seriously fun pool in the Glenroyal Hotel.)