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…
How not to check the validity of an email address
221–230 of 243 posts
Re: How not to check the validity of an email address
#222Re: How not to check the validity of an email address
#223Earlier 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?
Re: How not to check the validity of an email address
#224Gee, 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.)
Re: How not to check the validity of an email address
#225Re: How not to check the validity of an email address
#226Re: How not to check the validity of an email address
#227Every 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…
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
#228Earlier 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…
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
#229Re: How not to check the validity of an email address
#230Earlier 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. :)