Live data from Hacker News

How not to check the validity of an email address

dellsystem.me

221–230 of 243 posts

Re: How not to check the validity of an email address

#221

In college I was hired to build an auction site. I was billing my client $20 / hour and subcontracting out the work to some of my fellow classmates at $10 / hour. I was swamped with other work and didn't have much time to review the code. I just made sure it satisfied the specifications and shipped it. We launched the site and did a few hundred thousands dollars worth of transactions in the first 24 hours. Then somet…

This sounds like a scary story that nerds would tell by a fire while camping.

Re: How not to check the validity of an email address

#222
post #158

Earlier quoted context omitted.

Whenever something like that happens, this is my reference: http://developerexcuses.com

git commit -m "$(curl -s developerexcuses.com | sed -n '/ /{s/ ]*>//g;p}')"

Nice bit of sed. :-) Here's the best awk, I could muster:

  awk -F'>' -v RS='

Re: How not to check the validity of an email address

#223
post #196

Earlier quoted context omitted.

Came across this one yesterday, slightly paraphrased: boolean updateMsg(boolean pPassed) { if (pPassed) { incrMsgCounter(); logger.info("Message sent"); } else { logger.info("Failed to send"); return false; } return true; } Yes, the calling code actually checked the return value. The code is full of stuff like this. Somehow I've got a morbid fascination and can't stop marvelling at how grotesque it is. It even overpo…

What's so bad about this one? Other than its returning a boolean being pointless, I mean?

The code doesn't return just any boolean. No, it returns the boolean it was passed. And the calling code checks the result, what, against the boolean it passed in, I wonder? I'd worry about unintended side-effects depending on the language...

Re: How not to check the validity of an email address

#224
post #108

Gee, what a newb. Here's how to do it in O(1): return userNamesStr.indexOf(curForwardUserName) >= 0 ;) (I'd love to not have to explain sarcasm, but people have an incredible difficult time understanding it here.)

lol, I was thinking that too -- "but indexOf is faster..."

Re: How not to check the validity of an email address

#225
Hate to burst people's bubble here on the privacy of email addresses, but it's routine at universities to have open, relatively unprotected LDAP directories or even web listings. That said, under Canadian PIPEDA (privacy laws), email addresses are considered personal information, so this would be a severe breach... As are all the times I get CC'd a bulk email rather than BCC'd.

Re: How not to check the validity of an email address

#226
post #158

Earlier quoted context omitted.

Whenever something like that happens, this is my reference: http://developerexcuses.com

git commit -m "$(curl -s developerexcuses.com | sed -n '/ /{s/ ]*>//g;p}')"

There's also:

    lynx -dump -nolist developerexcuses.com

Re: How not to check the validity of an email address

#227
post #175

Every single legacy application I've ever worked on has had analogous code buried in it somewhere. An application I've just been "repairing" recently has a spot where it uses two separate queries to pull two full table sized lists of values, then manually joins them with a loop, and then manually re-orders the joined values into groups selectively ignoring some rows, and then embeds the the whole reordered list in a…

I'm starting to really dislike the term "legacy code". It implies the code is bad because it's old. It perpetuates the misconception that code gets "stale" and problems build up. But that's not true. "Legacy code" is bad because it's BAD. All code is "legacy code" because unless the project is brand new, it has some history. We just don't call good old code "legacy code" because it hasn't caused us any problems. Ther…

The only legacy code that people talk about is bad legacy code. People never fondly remember the function they wrote ten years ago that's still doing what it should do, no debugging required.

It's always the function that's been rewritten twenty times that gets labelled as legacy code.

Re: How not to check the validity of an email address

#228

Earlier quoted context omitted.

I've seen a surprising amount of code that does: if (aBoolean == true) { .... }

At university I worked with small unmanned aircraft. We had a crash due to a piece of code with this form: int landing_flag; ... if( landing_flag ) { do_landing(); } It was C code that pre-dated a boolean type. A single corrupt data packet in a wireless link made landing_flag == 2345923 (some arbitrary large value) and thus the landing routine was triggered mid-flight. We changed every instance of if( flag ) to if( f…

But that's not quite the same - older versions of C didn't have a real Boolean type so you could well run into those kinds of problems.

In a language that does have a proper Boolean type I still think checking equality with literal true/false values is a bit silly.

Re: How not to check the validity of an email address

#229
post #68

Earlier quoted context omitted.

Here here. There are plenty of people who have CS degrees and can't programme. Why else do we need "FizzBuzz".

It's "hear, hear!" - an abbreviation of "Hear him, hear him!".

This one annoys me as much as "bare with me"..

Re: How not to check the validity of an email address

#230
post #36

Earlier quoted context omitted.

> Every single legacy application I've ever worked on has had analogous code buried in it somewhere. I'm not old enough to be responsible for stuff like that but I am incompetent enough.

> I'm not old enough to be responsible for stuff like that but I am incompetent enough. Now that is a great conversation starter! I assume you think you know more than the senior/lead/architect on the team. You might, but have fun with that mentality. It's not sure to last. :)

Not old enough as in hasn't produced any legacy code yet. Not in the sense of avoiding senility.
Post reply on HN