Comment On What If Someone Types In " "?

Bob T. got sucked into one of those "maybe the new guy can figure it out!" problems, only to open the first page - and then subsequent pages - to see that all of the validation code looked like this... [expand full text]
« PrevPage 1 | Page 2Next »

Re: What If Someone Types In " "?

2007-12-07 08:20 • by Sandy (unregistered)
The real wtf is that three spaces is ok.

Re: What If Someone Types In " "?

2007-12-07 08:21 • by Kluge Doctor (unregistered)
What I wouldn't give for a TRIM function...

Hey, wait...!!!!

Re: What If Someone Types In " "?

2007-12-07 08:32 • by Ruben (unregistered)
Unbelievable that such programmers get serious jobs...

Re: What If Someone Types In " "?

2007-12-07 08:35 • by FooLman (unregistered)
Have you ever checked the requirements? What if it said: invalid input is empty string, or one or two spaces. Everything else should be considered valid.
How would you code that? :)

Re: What If Someone Types In " "?

2007-12-07 08:42 • by DOA
Screening for basic programming skill during the interview?! Don't be silly. If he says he can code, he can code.
The code is bad? But it works. Maintenance? I have deadlines to keep, I can't be bothered to think about the future. Just stop bothering me and go code stuff.
Mental note: fire that guy, he has a negative attitude.

Re: What If Someone Types In " "?

2007-12-07 09:00 • by GordonB (unregistered)
164572 in reply to 164569
With a regular expression.

Re: What If Someone Types In " "?

2007-12-07 09:08 • by John Doe (unregistered)
164574 in reply to 164569
FooLman:
Have you ever checked the requirements? What if it said: invalid input is empty string, or one or two spaces. Everything else should be considered valid.
How would you code that? :)

Simple: use a Regex! :)

Re: What If Someone Types In " "?

2007-12-07 09:09 • by AdT (unregistered)
The real..., ok, let's say another WTF is that the title is supposed to contain 4 spaces but Alex forgot about merging of consecutive whitespace characters in HTML so virtually every browser will only display one space. He should have used non-breaking spaces (  if the forum software lets me enter that. :-p )

Re: What If Someone Types In " "?

2007-12-07 09:12 • by Anon Fred (unregistered)
ooh, ooh, can i be the first to point out how three spaces looks like one space in HTML!?!!11one

Re: What If Someone Types In " "?

2007-12-07 09:12 • by meh (unregistered)
164577 in reply to 164564
Sandy:
The real wtf is that three spaces is ok.

If that is the case, what's the false/non-real/unreal wtf?

Re: What If Someone Types In " "?

2007-12-07 09:13 • by Anon Fred (unregistered)
164578 in reply to 164576
oooh, AdT beat me. :( :( :(

Re: What If Someone Types In " "?

2007-12-07 09:15 • by [ICR] (unregistered)
164579 in reply to 164569
FooLman:
Have you ever checked the requirements? What if it said: invalid input is empty string, or one or two spaces. Everything else should be considered valid.
How would you code that? :)


if(!IsValidInput(txtloginname.Text))
{
lblloginMessage.Visible=true;
lblloginMessage.Text = "Please Enter the User Id";
return;
}

if(!IsValidInput(txtcompanyname.Text))
{
lblloginMessage.Visible=true;
lblloginMessage.Text = "Please Enter the Company";
return;
}

...
}

public static bool IsValidInput(string text)
{
return !(text == "" || text == " " || text == " ");
}

Yes it uses double negation, but I prefer to think in terms of "Is this valid" rather than "Is this invalid".

Re: What If Someone Types In " "?

2007-12-07 09:20 • by jkohen
164581 in reply to 164569
With a loop, of course! (C++ RULZ, VB for kiddidz HA!!!)


bool b = true;
for (int i = 0; i < strlen(s); i++) {
if (s[i] != ' ') {
b = false;
goto GOOD; // VERY IMPORTANT 4 SPEED! remove this and puppy die!
}
}
if (b) {
// \a*3 = VERY laud BEEEP
return "\a\a\aYou have error!!!\n";
}
// Stpuid GCC give error label end of block. I wrote clever trick to shut up compiler.
GOOD: b = !!b;

Re: What If Someone Types In " "?

2007-12-07 09:35 • by akatherder
My buddy Darrell " " Simpkins always uses his nickname as his login id on websites. Not sure what he would do here. He's almost as bad as Smitty "Drop Users" Holmes.

Re: What If Someone Types In " "?

2007-12-07 09:36 • by Arancaytar
The real WTF is that the article title does not use forced nbsp spaces, which causes them to be rendered as a single space (superfluous HTML whitespace is invisible), so I only got the joke after viewing the document source. =P

Re: What If Someone Types In " "?

2007-12-07 09:39 • by morpcat
164586 in reply to 164575
AdT:
The real..., ok, let's say another WTF is that the title is supposed to contain 4 spaces but Alex forgot about merging of consecutive whitespace characters in HTML so virtually every browser will only display one space. He should have used non-breaking spaces (&nbsp; if the forum software lets me enter that. :-p )


Damn you and your beating everyone to the Alex-bashing!

Re: What If Someone Types In " "?

2007-12-07 09:39 • by FredSaw
I wonder what the problem was, that Telly was asked to solve.

I note that their label controls have a special naming convention: dromedary camel case.

Re: What If Someone Types In " "?

2007-12-07 09:40 • by morpcat
I'd also like to point out that not only could &nbsp; be used, but <pre> as well.

Re: What If Someone Types In " "?

2007-12-07 09:41 • by Sean (unregistered)
164589 in reply to 164585
Arancaytar:
The real WTF is that the article title does not use forced nbsp spaces, which causes them to be rendered as a single space (superfluous HTML whitespace is invisible), so I only got the joke after viewing the document source. =P


There should be a prize for finding the real WTF.

Re: What If Someone Types In " "?

2007-12-07 09:42 • by rawsteak
i r 1337 hax0rz, i r try break syst3m with 2 spaces... ohnoes! they check for it! i r deefeeted :(

Re: What If Someone Types In " "?

2007-12-07 09:42 • by Zecc
164591 in reply to 164575
AdT:
another WTF is that the title is supposed to contain 4 spaces but Alex forgot about merging of consecutive whitespace characters in HTML so virtually every browser will only display one space.


He's not alone, apparently.

Re: What If Someone Types In " "?

2007-12-07 09:43 • by Zecc
164592 in reply to 164588
morpcat:
I'd also like to point out that not only could &nbsp; be used, but <pre> as well.
Not inside <title> ...

Re: What If Someone Types In " "?

2007-12-07 09:55 • by morpcat
164593 in reply to 164592
Zecc:
morpcat:
I'd also like to point out that not only could &nbsp; be used, but <pre> as well.
Not inside <title> ...


It occurs once within <title>, once within the page. He should be using &nbsp; for <title>, but leave the three spaces in the body. That way, he can add a client-side script to the page to hardcode <pre> in as the page is generated.

Re: What If Someone Types In " "?

2007-12-07 09:59 • by dlikhten
WHAT ARE YOU DOING? The virtual crowd hates you! They want more blank spaces!

I guess the guy was paid by the character, not by usability of the product.

Re: What If Someone Types In " "?

2007-12-07 10:08 • by rbonvall (unregistered)
164595 in reply to 164572
GordonB:
With a regular expression.


Shhhh, don't mention it. Now someone will quote Zawinski.

Re: What If Someone Types In " "?

2007-12-07 10:11 • by Bartman (unregistered)
This is such an obvious WTF that even I got it after the first reading. That is some scary shitizzle fo shizzle...yo

Captcha is "poindexter" you busters

Re: What If Someone Types In " "?

2007-12-07 10:14 • by Someone (unregistered)
I don't get it, I write code like that all the time.... ;-)

Re: What If Someone Types In " "?

2007-12-07 10:44 • by Tp (unregistered)
This guy isnt just a bad coder, he is also stupid. Not knowing that this can be done with regex makes him a bad coder. Not seeing that the functionality he is implementing is completly bonko-bonko, is just brilliantly moronic.

Re: What If Someone Types In " "?

2007-12-07 10:58 • by Bob (unregistered)
164607 in reply to 164579
[ICR]:
FooLman:
Have you ever checked the requirements? What if it said: invalid input is empty string, or one or two spaces. Everything else should be considered valid.
How would you code that? :)


if(!IsValidInput(txtloginname.Text))
{
lblloginMessage.Visible=true;
lblloginMessage.Text = "Please Enter the User Id";
return;
}

if(!IsValidInput(txtcompanyname.Text))
{
lblloginMessage.Visible=true;
lblloginMessage.Text = "Please Enter the Company";
return;
}

...
}

public static bool IsValidInput(string text)
{
return !(text == "" || text == " " || text == " ");
}

Yes it uses double negation, but I prefer to think in terms of "Is this valid" rather than "Is this invalid".


Wow, just wow.... and when the requirements change comes down that companyname has a different rule than loginname, and some weak programmer modifies the isValidInput routine without proper testing.. Wait.. that's next week's WTF..

Re: What If Someone Types In " "?

2007-12-07 11:08 • by Cloak (unregistered)
164608 in reply to 164589
Sean:
Arancaytar:
The real WTF is that the article title does not use forced nbsp spaces, which causes them to be rendered as a single space (superfluous HTML whitespace is invisible), so I only got the joke after viewing the document source. =P


There should be a prize for finding the real WTF.


TRWTF is that they write JavaScript but use Microsoft prefixes for the labels and text boxes

Re: What If Someone Types In " "?

2007-12-07 11:16 • by volpone (unregistered)
164609 in reply to 164569
Have you ever checked the requirements? What if it said: invalid input is empty string, or one or two spaces. Everything else should be considered valid.

Then that systems analyst should have his intestines pulled out through this nostrils, onto death.

Re: What If Someone Types In " "?

2007-12-07 11:27 • by Ed (unregistered)
164610 in reply to 164607
Wait -- so you're actually suggesting that repeating the exact same lines of code multiple times rather than putting them in a function is a superior solution because we should always plan for inept programmers?

WOW, just WOW WOW WOWEEEE!!

If you had to plan for the "weak" programmers I used to work with, this little snippet would be 200 lines long.

Re: What If Someone Types In " "?

2007-12-07 11:27 • by T $
This example lacks recursion, I have instant dislike of it.

Re: What If Someone Types In " "?

2007-12-07 11:30 • by ParkinT
Since this is obviously Javascript client-side validation*,
every "return" should be return false!
Otherwise, the form is submitted with bad data and then, what's the point of validating at the client?

*The demonic shortcomings of client-side validation is a subject for a differnt discussion

Re: What If Someone Types In " "?

2007-12-07 11:38 • by DeLos
You know it is a real WTF if I can see it right away.

I normally read these things over 4 or 5 times (and some comments) before going "oooooh, i see!".

Re: What If Someone Types In " "?

2007-12-07 11:55 • by Tobby (unregistered)
Sounds like an XKCD moment...

"This form still accepts spaces! What are we gonna do?!?"

"Everybody stand back! I know regular expressions!"

Re: What If Someone Types In " "?

2007-12-07 12:03 • by Spectre
The real WTF is that they first set the label visibility, and then text, which leads to unnesessary flickering.

Re: What If Someone Types In " "?

2007-12-07 12:13 • by Jonneh (unregistered)
What is with the Constant Viagra ads?

Is this industry really plagued by ED? I've only just started out :[

Re: What If Someone Types In " "?

2007-12-07 12:23 • by Thogek
164620 in reply to 164567
Ruben:
Unbelievable that such programmers get serious jobs...
Unless you've been around enough of them in real employment situations, which many of us have. :-(

Then you just replace "unbelievable" with "frustrating as hell".

Re: What If Someone Types In " "?

2007-12-07 12:25 • by Thogek
164621 in reply to 164569
FooLman:
Have you ever checked the requirements? What if it said: invalid input is empty string, or one or two spaces. Everything else should be considered valid.
How would you code that? :)
Then I suppose the WTF would be in the requirements... :-O

Re: What If Someone Types In " "?

2007-12-07 12:37 • by snoofle
164622 in reply to 164619
Jonneh:
What is with the Constant Viagra ads?

Is this industry really plagued by ED? I've only just started out :[

Yes! It comes from staring at a monitor all day long.

Re: What If Someone Types In " "?

2007-12-07 12:42 • by justbeez
The real WTF is that so many people have wasted their brain cells posting "The real WTF is . . ." messages about such a sad little piece of code.

The fact that it exists is sad enough; let it die with a little bit of dignity!

Oh . . . wait . . . it never had any . . . my bad.

Continue the assault.

Re: What If Someone Types In " "?

2007-12-07 12:44 • by LiquidPT (unregistered)
164624 in reply to 164608
Cloak:
Sean:
Arancaytar:
The real WTF is that the article title does not use forced nbsp spaces, which causes them to be rendered as a single space (superfluous HTML whitespace is invisible), so I only got the joke after viewing the document source. =P


There should be a prize for finding the real WTF.


TRWTF is that they write JavaScript but use Microsoft prefixes for the labels and text boxes


That might be because it's not JS... It's C#. The properties being accessed sure look like server-side control properties to me.

Re: What If Someone Types In " "?

2007-12-07 12:45 • by LiquidPT (unregistered)
164625 in reply to 164618
Spectre:
The real WTF is that they first set the label visibility, and then text, which leads to unnesessary flickering.


Not if this is server-side C# code...

Re: What If Someone Types In " "?

2007-12-07 12:45 • by Ancient_Hacker
There used to be a major OS back in the old days where you could type "stop" to end any program.

The OS checked for equality against the strings "stop" and "STOP". But not any variants. So if you typed "Stop" or "STop" or STOp or sTOP or stOP or stoP it would continue on.

Or StoP or SToP or STOp.



Re: What If Someone Types In " "?

2007-12-07 12:52 • by Mogri (unregistered)
164629 in reply to 164622
snoofle:
Jonneh:
What is with the Constant Viagra ads?

Is this industry really plagued by ED? I've only just started out :[

Yes! It comes from staring at a monitor all day long.


This is probably the worst demographic for marketing Viagra: most programmers are young and many have trouble getting laid.

Re: What If Someone Types In " "?

2007-12-07 12:55 • by Velko (unregistered)
164631 in reply to 164613
ParkinT:
Since this is obviously Javascript client-side validation*,
every "return" should be return false!
Otherwise, the form is submitted with bad data and then, what's the point of validating at the client?

*The demonic shortcomings of client-side validation is a subject for a differnt discussion


IMHO it looks like C# - server-side validation @ASP.NET

Re: What If Someone Types In " "?

2007-12-07 13:00 • by Anon (unregistered)
164632 in reply to 164612
T $:
This example lacks recursion, I have instant dislike of it.

Good point. How about this validation function as a replacement (done in JavaScript):

[code]function isValid(str) {
if (str.length == 0)
return false;
if (str.substring(0,1) == " ")
if (validate(str.substring(1))) {
// Avoids tail recursion!
return true;
} else {
return false;
}
return true;
}

Re: What If Someone Types In " "?

2007-12-07 13:01 • by Willie Monkey
164633 in reply to 164629
Mogri:
snoofle:
Jonneh:
What is with the Constant Viagra ads?

Is this industry really plagued by ED? I've only just started out :[

Yes! It comes from staring at a monitor all day long.


This is probably the worst demographic for marketing Viagra: most programmers are young and many have trouble getting laid.

That's beacuse they spend so much time spanking the monkey that it won't come out to play any more; hence the need for Viagra!

Re: What If Someone Types In " "?

2007-12-07 13:15 • by Franz Kafka (unregistered)
164634 in reply to 164584
akatherder:
My buddy Darrell " " Simpkins always uses his nickname as his login id on websites. Not sure what he would do here. He's almost as bad as Smitty "Drop Users" Holmes.


wait, is that Drop users or '; drop users;--?
« PrevPage 1 | Page 2Next »

Add Comment