- 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
Other countries, for one thing. Off the top of my head Canada uses letters, and I'm sure it's not alone. Of course if other countries are remembered then the field is more apt to be called 'PostalZone' or the like.
Regardless, ISNUMERIC isn't useful since it allows non-numbers (commas, periods, and more) and would need a second check anyway. Since LIKE or TRANSLATE simply move the loops internally that aren't that much faster. While other ideas may work, the presented one is perfectly valid and there is nothing to indicate 'Andy' could think of everything discussed during its initial development. And I have a feeling if he wrote the test cases for it in the new Oracle system he wouldn't have thought of periods or an initial minus sign but just verified on 'XYZ' or other obvious cases.
Admin
I once wrote a geographic distance approximation server that determines mileage based on zip code deltas. This is how I worked out the formula:
Beverly Hills - Boston: 90210 - 02043 = 88167
Zip distance = 88167 (That's 90210 - 02043) Actual distance = 2605 miles. Ratio = 33.84
That's a pretty good sample to base all other possibilities on, so the function goes:
int distanceBetweenZipcodes( int zip1, int zip2 ) { int zipDist = abs(zip1 - zip2); return (int)((float)zipDist / 33.84F); }
You'd be amazed how accurate it is.
Admin
As long as posters like you take themselves too seriously, I'll be amused. Thanks for the entertainment. ;)
Admin
TRWTF* is the fact that the developer is proposing non-idempotent code to "optimize" something that absolutely doesn't require optimization (the bar code generation can't usefully go faster than either image generation of label printing), in a way which breaks predictability and comparability in an heterogeneous environment, does not properly validate in a bit of validation code, and wastes more man-hours exchanging idiotic e-mails with a manager who obviously has better things to do (and he looks like a good one, given the quality of the call made) than the total man-hours this optimization is ever likely to save over the entire life-cycle of the project.
I think the dev just needs something new to work on. He`s converting idle cycles into NOPs.
Admin
(should edit: "image generation of label printing" should read "image generation or label printing"; othger typos are offered as a bonus to the original content)
Admin
Admin
AKA hexatridecimal.
Admin
Beverly Hills to Ft. Lauderdale (33301) calculates to 1681 miles. Actual distance: 2700 miles.
Admin
Admin
(A real computer is any computer that does real work, instead of sitting on a desktop entertaining a bored, overpaid moron who can't remember if he's on the job, or home watching TV.)
Admin
because Canada has letters in their postal codes.
Admin
Not to mention TheDailyWTF would be without mandate if they didn't daily hurl (or at least rethrow) insults at people they've never met, for reasons they aren't even sure about. After all, that's how stories like today's get posted--a lack of perspectives, a lack of context, and a lack of domain knowledge.
Not that I care since when the WTF is on the poster it makes for just as good a story.
Admin
I agree. If there is any correlation between zip code and actual distances, it's a coincidence specific to a particular subset of US zipcodes.
You should NEVER being doing math based on zipcodes. Especially when there are free web services that can do the actual distance look ups for you. Not to mention as someone already pointed out canada has letters in their zip codes (I always thought it was the UK, but apparently canada does also).
There is a difference between a number, and a string containing only numeric digits. Each is a unique tool and has a unique scenario when it is appropriate.
Admin
A quick look at the zip code map and you'll see that, although it might look OK for some, there's many many holes.
Extreme example. Gulfport Mississippi to Slidell Louisiana.
Zip code difference: 30951 Projected distance: 915miles Actual distance: 45ish miles
Admin
Admin
The fact that proper ZIP codes have simple, ridgedly defined layout makes determining the non-numeric characters and their positions trivial. Just because an array of generic-characters is the closest thing to an array of class-of-characters, neither means it is the only valid way to store the information, nor means it is (in some cases) the most efficient for processing.
Admin
Instead of just throwing insults around, could you point out the flaw in my argument, or do you just get that extra zest for life that keeps you from shooting your sorry low-self-esteem brains by coming on the board and showing what a better man you are ?
(Hint 1: You do not hire people anyway, so you wouldn't be in a position to hire me; you are a sad loner. You probably don
t even have a girlfriend who loves you. Hint 2: I certainly wouldn't hire you. And I hire a lot of people. We don
t accept sad loners on the team. Happy loners yes. Sad ones bring everybody down.)Admin
In defense of the manager, this is obviously a 2 phase project.
Phase 1:
step 1) translate the code identically
step 2) validate the new code
Phase 2: upgrade/revise the new code base
Admin
I mean, you are not one of those geniuses who would spend even a single man-hour optimizing away what would amount to a few seconds of machine time over the lifespan of a non-real-time app are you ?
Admin
Is that you, Captain Kirk?
Admin
Here's the problem with is numeric.
Select ISNUMERIC('$12355.23').
Technically, that's a string, however ISNUMERIC() is "smart" enough to figure out you mean money.
Admin
Where's the WTF?
Admin
Oh my god you nailed me! How did you know? I lost my job as a manager and my girlfriend left me. I haven't had sex in four years!
But at least I don't reply to my own posts.
(Hint 0: My nickname "Single User" refers to the only computers you've ever seen, not to my relationship status. But nice try...)
Admin
Where's the WTF? Are you too retarded too understand that it does NOT exactly replicate ISNUMERIC(). Your boss is right and you should be fired.
Admin
You are forgetting that there is other country in the world than your stupid empire.
Admin
Admin
Admin
Junior did what juniors do, but was wise enough to discuss.
Manager praised junior for being pro-active, but realized this was not the time. End of discussion.
Admin
I was replying to a comment about ZIP codes. I assumed (perhaps incorrectly) that they were referring to USPS ZIP codes. I realize other countries have postal codes similar in purpose to USPS ZIP codes, that have different properties than USPS ZIP codes. If there are other countries that call their postal codes "ZIP codes", I am unaware of them, but I would interested to learn about these non-USPS postal ZIP codes.
Admin
Most English-speaking countries call them postcodes, but the Philippines (as a former US colony) refer to them as ZIP codes as well, apparently. http://www.nscb.gov.ph/activestats/zipcode/ for more information.
In any event, due to the pervasiveness of American television programmes throughout the world, it is highly likely that the term 'zip code' is interchangeable with 'postcode' - or at least understood as such.
Admin
Sigh... a simple googling provides (http://www.techonthenet.com/oracle/questions/isnumeric.php) that using
would be a valid test in this case, and will test for the correct length (depending on the barcode standard used).The manager was right in that case... if testing for barcodes, ISNUMERIC alone would not be equivalent to the provided code.
Captcha: saepius - S.A. Pius, a ship named after a pope?
Admin
How about Antelope, OR (97001) to Agana, Guam (96910)?
Zip code difference: 91 Projected distance: 2.6 miles Actual distance: 5787.7 miles
I hope you were joking about that algorithm...
Admin
Sounds pretty manager-ish to me
Admin
This is actually a valid approach by the manager.
It is quite easy to look at two pieces of PL/SQL and T-SQL code and verify that they perform the same. It's not so easy to look at a piece of PL/SQL code and know that it functions the same as a named T-SQL function without source code for that function.
In order to verify that they both perform the same, we would need to know that they both returned the same value for a null input; we would need to know that they returned the same value for an input which included padding spaces; we would need to know if they returned the same output for arbitrarily-long strings (the ISNUMERIC may convert to a 32- or 64-bit integer and fail for longer inputs); we would need to know what it does for inputs with leading zeros; we would need to know if works on integers or floats.
In short, there are too many edge cases where the behavior might vary, that it's safer to copy it as-is than replace it with something that may or may not behave exactly the same.
Since the stated goal of the project is to have the two systems "work exactly the same", the manager is taking the safest approach for ensuring that his project is completed correctly and on time.
I would likely do the same.
TRWTF is not the manager requesting identical code, but the original version's developer writing such strange code instead of using a library function.
Admin
Yadi yadi yada. All insults, not one single cogent or useful argument. You are a troll. Buzz off.
Admin
Eh. Anyone who has done a bit of this even remotely this type of work knows that when you change things, they break. Then you have to debug the system to get it working, at least if you're lucky enough to notice that it no longer works correctly...
Actually the case is often exact opposite of what's presented as the WTF. Original code uses a built-in/library function. The new system doesn't have a function that behaves exactly the same, there's a slight difference. So in the new environment, the original function is re-implemented instead of using the new environment's subtly different default function.
Admin
The real WTF is you expecting to get pilloried for saying somthing correct.
Admin
True. Here in Australia we use four digit postcodes, but we know that 'zip code' means the same thing. And at my workplace they're stored in a ZIPCODE column since our software platform is American. Fortunately, it's a string column so that we can accommodate the occasional customer with an address in the UK or wherever.
Of course, other than Australian postcodes, our members mainly use it for things like 'DO NOT CONTACT', but we have the occasional 'GU7 2PR' or whatever in there as well.
One thing about the original submission still puzzles me (the other good points have already been made). Why was the developer recommending IsNumeric in the language he was porting from, when it doesn't exist in the language he was porting to? Even if only integer-compatible strings were used and the currency and other "numeric" symbols were somehow not a problem, what was he hoping to achieve?
Admin
Admin
Admin
Admin
Nowhere on the name it says it will only accept cardinal numbers.
Admin
Making an extra trip to the network layer, a connection handshake, argumment passing, context switching if on the same machine, or waitting for a slow network connection if on different machines, and to top all, offloading work fom cheap and easily replicated resources (web servers) to expensive servers that won't replicate at all (as both Oracle and MSSQL won't), but even if the software were less of an WTF, would face several basic problems for replication, not being able to achieve proportional speedup.
No, no reason for calling the database everytime being a problem at all.
Admin
Are you sure you want to match END_OF_STRING, followed by some number characters, followed by BEGIN_OF_STRING?
Admin
Funny how easily offended (supposed) smart people are on a technology website dedicated to comedy. As a fellow programmer for 10+ years I have seen "Andys" try to prove their worth by tearing apart older systems. Competence begets maturity, both of which the "Andy" in the story sadly does not posses. Quickly seeing the "Andy" for the self-serving attention whore that he is should evoke a smile, not a discussion on Al Gore's politics.
Admin
The person who wrote the SQL Server function in the first place was a bit inexperienced, to be kind:
IF @Input LIKE '%[^0-9]%' BEGIN --non-numeric character in string END
Admin
Admin
Well done.
Admin
I'm amazed.
Admin
If "First" is the name of a numeric column in a table, and it contains a number...
What you are wanting to see, I think, is
IsNumeric('FIRST')
Double Quotes are identifiers... like column names.