Comment On There's Always Room to Expand

"I was going through old e-mail from several years back I ran into this gem," writes Lianna. "This snippet, with data anonymized, comes from the logs of the database as some of the queries that were performed by a particular PHP system:" [expand full text]
« PrevPage 1 | Page 2Next »

Re: There's Always Room to Expand

2012-08-16 08:02 • by Albertini Albertino (unregistered)
In that vein, then - coming soon, TDWTF...2.

Re: There's Always Room to Expand

2012-08-16 08:04 • by Zeroth? or 'A'th? (unregistered)
there's always room for expansion. If you need another column, just add a new one, adding one to the highest 'f column'.
Not so fast hotshot. What happens when you run out of numbers? Should have at least used hex, if not the entire alphabet, to buy more time.

Re: There's Always Room to Expand

2012-08-16 08:10 • by Richard (unregistered)
Hey, don't knock it, Alex does the same thing here with comments. Notice how each comment gets an incrementing number? The code looks something like this:

update wtf.article set c1440513 = 'In my country...' where article=1961720010330;

(Of course I'm assuming each comment is another column in the article row. That way you can fetch them all at once instead of having to loop through SELECT results.)

Re: There's Always Room to Expand

2012-08-16 08:13 • by Some Jerk
FINALLY... a REAL WTF! It has been days since I had a good vomit!

I wish I could see the entire workflow that made it necessary to update a single row, one column at a time :p. I am guessing it was tied to the onchange event on an html form, causing an ajax post every time a form element value was modified. Would be interesting to see if this "ENGINEER" had bothered to sanitize the input.

Re: There's Always Room to Expand

2012-08-16 08:14 • by Codd (unregistered)
update tmp set f7 ='Somestreet' where f0=1961720010330;
update tmp set f8 ='123' where f0=1961720010330;
update tmp set f9 ='1001' where f0=1961720010330;
update tmp set f10 ='AA' where f0=1961720010330;
update tmp set f11 ='SOME CITY' where f0=1961720010330;
Obviously this is a data entry screen where the user is filling out a form. You want to save each value as they enter it instead of waiting for the end and possibly losing everything due to a power failure or whatever.

Re: There's Always Room to Expand

2012-08-16 08:14 • by Some Jerk
387401 in reply to 387398
Richard:
Hey, don't knock it, Alex does the same thing here with comments. Notice how each comment gets an incrementing number? The code looks something like this:

update wtf.article set c1440513 = 'In my country...' where article=1961720010330;

(Of course I'm assuming each comment is another column in the article row. That way you can fetch them all at once instead of having to loop through SELECT results.)


hey... don't pick on Alex. If he wants to go to huge lengths just to wtf us with HTML comments... then that just shows his level of committment to fuckery!

Re: There's Always Room to Expand

2012-08-16 08:16 • by Bobby (unregistered)
Well at least if there's an SQL injection hole (and there most likely is) you don't have to worry about the hacker figuring out your data structure when he downloads your database.

Re: There's Always Room to Expand

2012-08-16 08:16 • by Some Jerk
387403 in reply to 387400
Codd:
update tmp set f7 ='Somestreet' where f0=1961720010330;
update tmp set f8 ='123' where f0=1961720010330;
update tmp set f9 ='1001' where f0=1961720010330;
update tmp set f10 ='AA' where f0=1961720010330;
update tmp set f11 ='SOME CITY' where f0=1961720010330;
Obviously this is a data entry screen where the user is filling out a form. You want to save each value as they enter it instead of waiting for the end and possibly losing everything due to a power failure or whatever.


yea... because then if there really is a power failure... all the person updating the form has to do to finish up is remember that the ID is 1961720010330, and know where to put it to prepopulate his old data. How hard can that POSSIBLY be?

Re: There's Always Room to Expand

2012-08-16 08:18 • by Carl (unregistered)
update tmp set f75 ='' where f0=1961720010330;
Yeah, because it we didn't set it to '' it would have defaulted to, um, what? Blank?

Re: There's Always Room to Expand

2012-08-16 08:20 • by Some Jerk
387405 in reply to 387404
Carl:
update tmp set f75 ='' where f0=1961720010330;
Yeah, because it we didn't set it to '' it would have defaulted to, um, what? Blank?


NULL

Re: There's Always Room to Expand

2012-08-16 08:22 • by Easy (unregistered)
387407 in reply to 387403
Some Jerk:
Codd:
update tmp set f7 ='Somestreet' where f0=1961720010330;
update tmp set f8 ='123' where f0=1961720010330;
update tmp set f9 ='1001' where f0=1961720010330;
update tmp set f10 ='AA' where f0=1961720010330;
update tmp set f11 ='SOME CITY' where f0=1961720010330;
Obviously this is a data entry screen where the user is filling out a form. You want to save each value as they enter it instead of waiting for the end and possibly losing everything due to a power failure or whatever.


yea... because then if there really is a power failure... all the person updating the form has to do to finish up is remember that the ID is 1961720010330, and know where to put it to prepopulate his old data. How hard can that POSSIBLY be?
You are clearly failing to grasp this design pattern. This can easily be fixed using the following:

update allvars set f1903 = 1961720010330 where rowname = 'users_last_active_row';

Re: There's Always Room to Expand

2012-08-16 08:52 • by jonnyq
This is not a WTF:
- these are query logs. there may be comments in the code, and this is out of context, so maybe this makes more sense in context
- Yes, it's a silly "clever" trick someone thought was a good idea at the time when there's like a much better way, but:
- even the OP admits to clearly knowing which fields were zip codes, even when the fields changed and so on
- there weren't any maintenance issues. it did its job for as long as it needed to
- and it got replaced with something more sensible before it became a problem

Re: There's Always Room to Expand

2012-08-16 08:52 • by TGV
O man, this is so inefficient. I've already described the db on which I had the pleasure to work: it had a similar design, but had a "vtypeid" which indicated how to interpret the row of data. Obviously, there were vtypeids that overlapped.

However, it was way more efficient than this one. We had 5 columns, and didn't have to add columns, we just added another row with a different vtypeid and then ... (wait for it) ... joined multiple queries that shared the same source id and timestamp. If the above design made someone vomit, this one will have him slash his wrists (remember: across the arm, not across the wrist).

That didn't hinder anyone in creating databases with 4, 9 or 13 columns, of course. It did hinder everyone though in writing portable queries.

Re: There's Always Room to Expand

2012-08-16 09:03 • by Evoex (unregistered)
I like the Dutch word "bestaand" in there, which means "existing". As a string...

Re: There's Always Room to Expand

2012-08-16 09:22 • by Some Jerk
This reminds me of a company standard from a former job, to add an extra 10 parameters to every asp/vbscript function just in case they will be used later. As a result, you would have:

function chokeYourself(secondsToDeath, numberOfHands, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, parameter10, parameter11, parameter12)
... code
end function

then, if you decided you wanted to specify the number of spectators later, you could simply substituted the name "parameter3" for "numberOfSpectators" without breaking any of the function calls. The vbscript (obviously) would already be expecting the correct number of parameters, so nothing could possibly go wrong... right?! <YAKKK!>

Re: There's Always Room to Expand

2012-08-16 09:41 • by Wonk (unregistered)
387414 in reply to 387409
jonnyq:
This is not a WTF:
- these are query logs. there may be comments in the code, and this is out of context, so maybe this makes more sense in context
- Yes, it's a silly "clever" trick someone thought was a good idea at the time when there's like a much better way, but:
- even the OP admits to clearly knowing which fields were zip codes, even when the fields changed and so on
- there weren't any maintenance issues. it did its job for as long as it needed to
- and it got replaced with something more sensible before it became a problem


oh, how I miss TopC0der.

Re: There's Always Room to Expand

2012-08-16 09:45 • by Another Jerk (unregistered)
I'm always wanting to use the most cryptic parameter names possible to that nobody will be able to follow what I have done.

Re: There's Always Room to Expand

2012-08-16 09:51 • by Some Jerk
387417 in reply to 387415
Another Jerk:
I'm always wanting to use the most cryptic parameter names possible to that nobody will be able to follow what I have done.


a design pattern something like this?:

public class enum1
{
public enum VOID
{
ZERO = 2
ONE = 0
TWO = 1
}
public int StringProperty1 {get; set;}
public string IntProperty2 {get; set;}
public VOID Event( string boolValue )
{
if( boolValue == "ZERO" )
return VOID.ONE;
else
throw new NullReferenceException( "YOU SUCK!" );
}
}

Re: There's Always Room to Expand

2012-08-16 10:25 • by Callin
There's always room for another thousand columns. As long as you can store the data somehow, somewhere, you're good.

Re: There's Always Room to Expand

2012-08-16 10:42 • by ¯\(°_o)/¯ I DUNNO LOL (unregistered)
TRWTF is not knowing the difference between a database and a spreadsheet. Or PHP.

Re: There's Always Room to Expand

2012-08-16 10:45 • by Double Click (unregistered)
I am not sure If this is WTF or not. I just happen to stumble on it.

Try double click on the code in the article. And see what happens.

BTW I am using FF14 on Win7 64bit

Re: There's Always Room to Expand

2012-08-16 11:03 • by Another (unregistered)
387421 in reply to 387412
Some Jerk:
This reminds me of a company standard from a former job, to add an extra 10 parameters to every asp/vbscript function just in case they will be used later. As a result, you would have:

function chokeYourself(secondsToDeath, numberOfHands, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, parameter10, parameter11, parameter12)
... code
end function

then, if you decided you wanted to specify the number of spectators later, you could simply substituted the name "parameter3" for "numberOfSpectators" without breaking any of the function calls. The vbscript (obviously) would already be expecting the correct number of parameters, so nothing could possibly go wrong... right?! <YAKKK!>
And this, ladies and gentlemen, is why the gods gave us perl.

sub chokeYourself {
my ($secondsToDeath, $numberOfHands) = @_;
...
}

Caller passes extra params? No problem. Update sub to receive $numberOfSpectators, but some callers don't know? No problem again. Just make sure the sub's code gracefully deals with a null $numberOfSpectators.

Re: There's Always Room to Expand

2012-08-16 11:05 • by Neil (unregistered)
387422 in reply to 387420
Double Click:
I am not sure If this is WTF or not. I just happen to stumble on it.

Try double click on the code in the article. And see what happens.

BTW I am using FF14 on Win7 64bit
Seems to work better on the syntax highlighter demo page, the textarea replaces the code block. Dunno what the point is though, the manual seems to be incomplete.

Re: There's Always Room to Expand

2012-08-16 11:09 • by Kivi
Proven fact: if the database doesn't want to process your request, you can trick it by hiding the request among a bunch of other requests.

In other words, this whole block of code is just a ruse to get the database to do this:
update tmp set f76 ='p' where f0=1961520010330;

Re: There's Always Room to Expand

2012-08-16 11:11 • by Kivi
387424 in reply to 387404
Carl:
update tmp set f75 ='' where f0=1961720010330;
Yeah, because it we didn't set it to '' it would have defaulted to, um, what? Blank?

Shh, it's part of the ruse!

Re: There's Always Room to Expand

2012-08-16 11:12 • by snoofle
387425 in reply to 387419
¯\(°_o)/¯ I DUNNO LOL:
TRWTF is not knowing the difference between a database and a spreadsheet. Or PHP.
Wait, there is a difference?

Re: There's Always Room to Expand

2012-08-16 12:06 • by Man in pain (unregistered)
I invite all interested parties to look at an ExpressionEngine database.

After you stop screaming, you may take your meds and go back to your life, knowing that you don't have to deal with it.

Re: There's Always Room to Expand

2012-08-16 12:18 • by Dulton (unregistered)
387431 in reply to 387411
Yup, it's a dutch system alright. The postal codes are stored in the dutch "9999 ZZ" format.

Re: There's Always Room to Expand

2012-08-16 12:21 • by dogmatic (unregistered)
387432 in reply to 387403
Some Jerk:


yea... because then if there really is a power failure... all the person updating the form has to do to finish up is remember that the ID is 1961720010330, and know where to put it to prepopulate his old data. How hard can that POSSIBLY be?


You could easily restore the user's state by reading a cookie or having them login when they return.

Re: There's Always Room to Expand

2012-08-16 12:23 • by cellocgw
387433 in reply to 387405
Some Jerk:
Carl:
update tmp set f75 ='' where f0=1961720010330;
Yeah, because it we didn't set it to '' it would have defaulted to, um, what? Blank?


NULL

FileNotFound, of course

Re: There's Always Room to Expand

2012-08-16 13:10 • by TGV
387438 in reply to 387425
snoofle:
¯\(°_o)/¯ I DUNNO LOL:
TRWTF is not knowing the difference between a database and a spreadsheet. Or PHP.
Wait, there is a difference?

OMG, you didn't go to college, did you? That's where you learn the difference between column names in a database, like f1, f2, etc., and those in spreadsheets: A, B, C. Duh.

Re: There's Always Room to Expand

2012-08-16 13:20 • by Some Jerk
387439 in reply to 387438
TGV:

OMG, you didn't go to college, did you? That's where you learn the difference between column names in a database, like f1, f2, etc., and those in spreadsheets: A, B, C. Duh.
You are either joking or totally daft.

Re: There's Always Room to Expand

2012-08-16 13:40 • by Gurth
387441 in reply to 387421
Another:
And this, ladies and gentlemen, is why the gods gave us perl.

sub chokeYourself {
my ($secondsToDeath, $numberOfHands) = @_;
...
}

Caller passes extra params? No problem. Update sub to receive $numberOfSpectators, but some callers don't know? No problem again. Just make sure the sub's code gracefully deals with a null $numberOfSpectators.

Even Visual Basic can do that:
Function chokeYourself(secondsToDeath As Long, numberOfHands As Byte, Optional numberOfSpectators As Double = 0)


End Function

Re: There's Always Room to Expand

2012-08-16 13:43 • by Some Jerk
387442 in reply to 387441
it is vbscript

optional params myArg

Re: There's Always Room to Expand

2012-08-16 13:46 • by the beholder (unregistered)
387443 in reply to 387442
Some Jerk:
it is vbscript

optional params myArg
A tip for you: when whatever is being said in a comment is true, it doesn't need to be corrected.

Re: There's Always Room to Expand

2012-08-16 13:49 • by Some Jerk
387444 in reply to 387442
and I might add that this actually resulted in a lot of silent errors in their app. They had several cases where they did not remember that certain regions of code were calling a method that was modified. At times, the new parameter was relavent information that was supposed to be deposited into a field on their new database (as they moved from foxpro to SQL Server). They didn't get any errors, so they assumed everything was functioning correctly... not realizing all the while that certain billing items were not associated with the client to whom the bill was to be sent.

There is a good reason to invalidate calls to functions that preceed said modifications... and unflatulantly they learned this lesson too late.

Re: There's Always Room to Expand

2012-08-16 14:05 • by Some Jerk
387445 in reply to 387443
the beholder:

A tip for you: when whatever is being said in a comment is true, it doesn't need to be corrected.


that is... errr... an interesting observation... by some standard :p

Re: There's Always Room to Expand

2012-08-16 14:35 • by herby
Now for something a bit off topic...

Is is just me, or is anyone else getting script exceptions (Java coloring or some such) when the current WTF loads. This just started happening for me a few days ago. It seems to correlate with the code lines displayed. Hitting 'OK' (many times) seems to work around it.

We now return you to the standard WTF commenting drivel that we all wish we could find "FILE NOT FOUND" in a binary return set. Hi Paula Bean, etc...

Re: There's Always Room to Expand

2012-08-16 14:55 • by Silent D (unregistered)
There must be some NOT NULL constraints that mess up this beautiful design pattern, requiring the INSERT to address three columns at once. That clearly needs to be refactored.

Could be worse, though, at least the database isn't based on the EAV abomination.

Re: There's Always Room to Expand

2012-08-16 16:19 • by Coyne
The first line suggests that there's always room to add another row, as well as adding another column.

Looking at the ID...


cust tbl order#
1961 5 20010330 i.e., the address row for the order
1961 7 20010330 i.e., the shipping address for the order
1961 8 20010330 i.e., the credit card info for the order
etc.


Which makes this truly a 2nd order WTF, which is a whole new level of WTF.

Just think, we cold have rows 1961020010330 thru 196190010330; and then 1961A20010330 thru 1961Z20010330; and then 1961a20010330 thru 1961z20010330; and then rows like 1961!20010330, 1961$20010330, 1961_20010330, and 1961{20010330. We could even have rows containing an 0x07 character in that position.

Why, we could have lots of rows!

Re: There's Always Room to Expand

2012-08-16 16:36 • by dolor (unregistered)
387449 in reply to 387404
[quote user="Carl"][quote]update tmp set f75 ='' where f0=1961720010330;[/quote]Yeah, because it we didn't set it to '' it would have defaulted to, um, what? Blank?[/quote]

haha - Carl thought for himself, let me say something that everyone will think it's cool, so that I clearly show that I'm mocking the original coder just like they're all obviously doing - even though I have no clue why everyone is laughing, but I will laugh with them so that they don't think I stupid - ok, let me say this [SARCASTICALLY, OUT LOUD]:

"update tmp set f75 ='' where f0=1961720010330;[/quote]Yeah, because it we didn't set it to '' it would have defaulted to, um, what? Blank?"

What Carl didn't realize was that he just showed us all how he doesn't understand even the basic SQL syntax or how values are stored in table. It has to be set to something - what? am I supposed to skip it, only because you don't like empty strings, and somehow remember that it's really blank while it's still equal some value, only because you don't like empty strings?

The NULL guy did try to help Carl understand, but we cannot assume that the field was nullable; so, I still stand behind this: Carl, shut the fuck up, you have a lot to learn.

Re: There's Always Room to Expand

2012-08-16 16:41 • by dolor (unregistered)
387451 in reply to 387446
herby:
Now for something a bit off topic...

Is is just me, or is anyone else getting script exceptions (Java coloring or some such) when the current WTF loads. This just started happening for me a few days ago. It seems to correlate with the code lines displayed. Hitting 'OK' (many times) seems to work around it.

We now return you to the standard WTF commenting drivel that we all wish we could find "FILE NOT FOUND" in a binary return set. Hi Paula Bean, etc...


It's just you. IE user? Now, THAT'S a real WTF today.

Re: There's Always Room to Expand

2012-08-16 17:18 • by Agention (unregistered)
387454 in reply to 387421
Another:
And this, ladies and gentlemen, is why the gods gave us perl.

sub chokeYourself {
my ($secondsToDeath, $numberOfHands) = @_;
...
}

Caller passes extra params? No problem. Update sub to receive $numberOfSpectators, but some callers don't know? No problem again. Just make sure the sub's code gracefully deals with a null $numberOfSpectators.


undef, you insensitive clod!

Re: There's Always Room to Expand

2012-08-16 17:58 • by Carl (unregistered)
387455 in reply to 387449
dolor:
...rant...
Wow, looks like I got you so pissed that you forgot to use the preview button!

Re: There's Always Room to Expand

2012-08-16 19:14 • by Some Jerk
387459 in reply to 387451
dolor:

It's just you. IE user? Now, THAT'S a real WTF today.

that has to be the stupidest thing I have seen on this site (including the wtfs) in a very long time. Whether or not a person uses IE implies absolutely nothing of value, except whether or not they use IE. There are no functional limitations that render an inferior product... no possiblity of brain damage... and no other reason why using IE would cause a specific reaction or judgement toward any comment or artical. You may as well well assume that a specific response was the result of somebody wearing blue wranglers that were a bit too loose around the waist, as to assume that the usage of Internet Explorer has some impact on exactly what text appears beneath their names. Therefore, I must say that the intelligence displayed in producing this posting rivals, at best, that of my 7 year old daughter, who can also type arbitrary responses to specific comments without spelling errors.

Re: There's Always Room to Expand

2012-08-16 20:37 • by scooby509
This isn't a WTF. It's worse.

It's an EAV, which is a horrible, horrible idea, but it is thoroughly documented horribleness that anyone who has worked with databases for a while has seen.

I say thoroughly, not well, because the majority of writing on EAV is total waffle-think that will spend twenty thousand words on metadata and clouds without ever touching on what anything is supposed to mean or why the hell you'd want to rewrite your DBMS in the first place.

Why do people do it? Because just as people try to optimize without knowing what they're optimizing or any proof that they need to, people also try to implement features without knowing what features they need or having any indication that the features are wanted.

EAV is the ultimate example of that: instead of nailing down the business logic, you just throw your hands in the air and say, "fuck it, let the users make it up as they go along."

Re: There's Always Room to Expand

2012-08-16 20:52 • by scooby509
387461 in reply to 387459
Some Jerk:
dolor:

It's just you. IE user? Now, THAT'S a real WTF today.

that has to be the stupidest thing I have seen on this site (including the wtfs) in a very long time. Whether or not a person uses IE implies absolutely nothing of value, except whether or not they use IE. (blah blah waah waah blah blah waah waah)


You're on a technical site, using a hopelessly broken browser and bitching about how you can't see the site, in spite of the fact that there are free ones available that work.

PEBCAK.

Re: There's Always Room to Expand

2012-08-16 20:57 • by scooby509
387462 in reply to 387449
dolor:
Carl, shut the fuck up, you have a lot to learn.


But not from the guy who can't figure out how to post a comment correctly.

Re: There's Always Room to Expand

2012-08-16 21:54 • by Some Jerk
387463 in reply to 387461
scooby509:
Some Jerk:
dolor:

It's just you. IE user? Now, THAT'S a real WTF today.

that has to be the stupidest thing I have seen on this site (including the wtfs) in a very long time. Whether or not a person uses IE implies absolutely nothing of value, except whether or not they use IE. (blah blah waah waah blah blah waah waah)


You're on a technical site, using a hopelessly broken browser and bitching about how you can't see the site, in spite of the fact that there are free ones available that work.

PEBCAK.


I use FF, Safari and IE interchangably... just whatever window happens to come up. I suppose that (in your ignorance) you were blissful enough to lay downa comment that had absolutely no substance whatsoever.

name 1 way that Internet Explorer is either not free or actually broken. Plenty (meaning 2 or 3) people commenting on it... but I PERSONALLY think that you simply dont like that fact that IE is owned by a multi-billion dollar company and is not open source. I have worked on websites (for a living) for 13 years. All I have seen is DIFFERENT behaviors. I haven't seen any proof that lead me to believe that any browser is better than another... in fact... I have always been able to replicate all functionalities in all browsers.

I suppose this goes to show... if anything works in one browser and not another (at least, recent browser, as all of the main ones are available for free) ... that is a WTF on the MORON who wrote it. you idiots that think one browser is in some way better than another are obviously too lazy or incompetant to learn how to do your jobs, and may as well shut the hell up... because there isn't a damned thing that can be done with one browser and I can't do with every browser used by at least 5% of the population

Re: There's Always Room to Expand

2012-08-16 22:24 • by Friedrice the Great (unregistered)
387464 in reply to 387463
Some Jerk:
scooby509:
Some Jerk:
dolor:

It's just you. IE user? Now, THAT'S a real WTF today.

that has to be the stupidest thing I have seen on this site (including the wtfs) in a very long time. Whether or not a person uses IE implies absolutely nothing of value, except whether or not they use IE. (blah blah waah waah blah blah waah waah)


You're on a technical site, using a hopelessly broken browser and bitching about how you can't see the site, in spite of the fact that there are free ones available that work.

PEBCAK.


I use FF, Safari and IE interchangably... just whatever window happens to come up. I suppose that (in your ignorance) you were blissful enough to lay downa comment that had absolutely no substance whatsoever.

name 1 way that Internet Explorer is either not free or actually broken.


1. You have to buy Windows to get Internet Explorer. Therefore it is not free.

2. Any version of IE<9 is broken. And at least the version of IE you use seemed to have problems with the site.

Q.E.D.
« PrevPage 1 | Page 2Next »

Add Comment