- 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
OK...
Admin
Gah! My bad, so nevermind.
Admin
This looks very VB to me. VB isn't bad, but there are alot of bad VB programmers.
C too hard C++ too hard Java too hard oh wait, here's a language I can figure out.
I hate VB not because of the language. Its because of all the BS artist that claim they can program in it.
Admin
The Imaginary WTF is that sqrt(-1) spaces would work...
Admin
I once attempted to write a whole space-invaders game like that.
10 PRINT " ^" 20 IF INKEY$="O" THEN GOTO 50 30 IF INKEY$="P" THEN GOTO 90 40 GOTO 20 50 PRINT " ^ " 60 IF INKEY$="O" THEN GOTO 130 70 IF INKEY$="P" THEN GOTO 170 80 GOTO 60 90 ...
But to be fair, I was 11.
Admin
Why do I not think you're being sarcastic?
Admin
Are you sure this is client-side? It looks like server side ASP.NET. In which case, this should be re-written using an ASP.NET Regular Expression Validator which would run as client-side java script (but also checked on the server side using the Page.IsValid property to ensure that someone hasn't bypassed the client-side validation.
Admin
With a chisel.
In the author's forehead.
Admin
Should be:
Wow, just wow...
Admin
So in your mind all programmers should write crappy code so that crappy programmers won't mess up good code? Doesn't that turn everyone into crappy programmers?
Admin
Admin
That requirement just came down from my lead not 2 hours ago. Luckily I'll have her job in two weeks.
Admin
I agree 100% I was just about to say that I only miss the comments, and I am really suprised now that there's someone else who also suggest putting links in comments. I thought that was only my perversion.
Admin
I'm afraid that you should have used a functor instead. It's a lot easier to understand and maintenance is a breeze.
Admin
die "invalid input: $input" if $input =~ /^ {0,2}$/;
(No, that's not in the same programming language as the code in the article, but since I don't actually know what programming language the original code was in, I just wrote my answer in my language of choice.)
Admin
public bool IsValid(string text) { // Invalid texts are the empty string, // one space, or two spaces return !(text.Length <= 2) || !(text.Trim() == ""); }
if(!IsValid(txtloginname.Text)) { lblloginMessage.Visible=true; lblloginMessage.Text = "Please Enter the User Id"; return; }
if(!IsValid(txtcompanyname.Text)) { lblloginMessage.Visible=true; lblloginMessage.Text = "Please Enter the Company"; return; }
if(!IsValid(txtchangereason.Text)) { lblloginMessage.Visible=true; lblloginMessage.Text = "Please Enter the Change Reason"; return; }
Of course, I would probably also condense the three if statements given how repetitive their logic is.
Admin
Some people, when confronted with a problem, think "I know, I’ll use regular expressions." Now they have two problems.
Admin
(And FTR, this is an obvious case for regexps. And a number of other things -- see above. Nothing wrong with regexps -- they solve problems to do with "strings". It would be nice to think that we're all into higher abstractions than "strings" these days, but ... well ... WTF.)
XML is not an acceptable higher-level abstraction for "string," incidentally.
Admin
Don't be too upset... in this industry having problems with the man downstairs makes no difference at all ;-)
Admin
If only we could use these poor individuals in studying raptor attacks.
Yes it is cruel to the raptors.
Admin
Ya ... I seriously think that someone broke your CAPTCHA system ...
Admin
dammit ci plus plus, what do you think you are doing? Your code does not have any GO TO's
Admin
Very funny! Thanks for the good laugh!
Admin
Is this ActionScript code? It looks like it. ActionScript doesn't have a trim function. Which is probably why this programmer was doing this silliness. Time to make your own trim function.
Admin
There was such thing in one of my project too! This is really bad code, but we can understand why when you see something like this :
<input name="loginname" value=" <?= $txtloginname ?>"/>Because each time the form is reloaded, a blank is inserted and they want to avoid that. So if the user enter "", it reload with value " ", and then " ", etc.
Admin
{ if comment = true } POST {comment} comment Lorem ipsum whatever. } {function VALIDATE true [if]} } endif true SUBMIT [if] }