- 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
Why does it have to be oracle and ms sql to start the day? :(
``unholy evil prophets rise fire is raining from the endless skies can you hear the final thunder roaring oracle in the morning''
Admin
ISNUMERIC("First") = TRUE; // what ??
Admin
The boss has a point, after all ISNUMERIC() accepts values that the PL/SQL While... piece o' crap would have rejected. Examples '+' , '-', ...
Admin
Does ISNUMERIC() return "true" for values with decimal points? What about negative numbers? Or leading/trailing spaces?
The original version would fail in those cases.
Admin
Hmmm. In this case, I agree with the manager. IsNumeric will say that "5.3" is ok, which is not what the original code would accept.
However, a try/catch block may not be the best way to do this.
How about writing a test harness, using XML to pass the data around ... with some more Enterprise-y WTF-ness? Then you can test the original and rewritten one to make sure they get the same results?
Admin
Garr !!
capture "cansequat" : what happens when you are quat. !!
Admin
I think TRWTF is "Select 'Non-Numeric Sequence Provided'" instead of RAISERROR().
Admin
The T-SQL ISNUMERIC function returns True for characters that can appear in numbers, such as currency symbols, exponation and plus/minus signs, so its behaviour would be different from the character-by-character approach used.
Admin
if isnumeric(@ORACLEWTF) RAISERROR ('cannot deal with oracle frist thing in morning', 16, 1)
captcha:enim - I need an enima after this article to cleanse my brain
Admin
I don't get it - where is the wtf ? Is it so much unbelievable that the manager would simply choose the safe path ?
Admin
Clueless manager is clueless. Where's the WTF?
Admin
Good to know the proximity of where you keep your brain...
Admin
Stored procedures are so Enterprise 1.0. Isn't there a cloud computing platform that'll do this for you?
Admin
So what Andy means to tell us is that "123456.789E17" is a valid barcode string in their system? And also "$123456.789"?
Admin
Ah, TheDailyNotAWTF. Shouldn't there be a series tag for that already?
Admin
You can not use ISNUMERIC for checking barcodes, as a barcode does not have to fit into an INT. For example, the EAN-13 barcodes contain 13 digits.
The original developer is correct. Manager is right. Andy should stick to his task.
Admin
Old solution seems fine to me, though there's probably a dozen cleaner and simpler ways to do it.
It's more that the new proposed solution wouldn't work.
cast('123.45' as int) will happily be converted in SQL (as it should), and I'd assume IsNumeric('123.45') would work too, as 123.45, well, is numeric.
Admin
I completely agree... However the original developer could have used more efficient methods to validate each digit rather than a try-catch..
something like (ch >= '0') And (ch <= '9')
Admin
The RWTF is that the code this snippet is embedded into presumably gets passed a string, when it should be passed an integer. Must have been written by one of those dynamically typed language loving cretins.
Admin
TRWTF is that Andy went to his boss to talk about implementation details. Only newbies do this. Experienced developers get the gist of what has to be done and keep the implementation to themselves. They do not discuss low-level code issues with management, because there is a very real risk that some clueless manager might start coming up with brillant ideas of the type "we should use XML because I keep hearing about it" and "we need to write this application in AJAX"
Admin
Ignoring the whole "ISNUMERIC is the wrong tool" issue (let's be nice and assume there's an ISINTEGER (or a regexp) and it would be used instead), the conversation should have ended like this:
"We just can't run the risk of the new Oracle code behaving any differently than the SQL Server version does. However, you should put your version in there as well, just as comments, so the next guy knows what's going on and doesn't resubmit this to TDWTF."
Admin
AFAIK passing a string is correct. Or is a barcode starting with 0 not valid?
Admin
I dunno...it seems perfectly reasonable to ask that a piece of production code, which probably interacts with a great many equally warty codes, do the exact same thing, at least at first. I could see implementing Andy's fix down the road (or rolling into the SQL Server code, if it weren't being transitioned to Oracle), but starting out by changing things just seems like a bad idea.
Now, before I get pilloried, let me explain. There're inevitably going to be bugs in the transition from SQL Server to Oracle, and being able to say "we implemented it the exact same way as before" provides a basis on which to debug. You can compare the two codes line by line, and figure out what didn't get translated correctly (or what function has different side effects, &c). While that code snippet probably doesn't have any funny side effects, it's possible that another one might, and "improving" the code as you translate could introduce/get rid of side effects that could change the behavior of the system. There's a time and place for improvement, but that just seems like it's premature--I agree with Andy's boss on this one.
Admin
Wow...
Not expecting a quote from Sodom's lyrics on the Daily WTF!
Admin
Why the hell is data converted to/from barcodes by the database?
This is a task that the normal language (Php/Java/.net I guess) can do much faster, and without an insane implementation.
Admin
Oh, so true. As someone once said, "The surest way to cause your supervisor to fail is to follow his every order without question." And people wonder why computers are frustrating.
Admin
Clueless programmer is clueless. Where's the WTF?
Admin
So write some unit tests and make sure they pass with the new code. You should do this anyway.
Admin
Assuming the string has to be something that can be printed as an EAN (UPC, GTIN...) barcode, then the original version is more correct than a simple ISNUMERIC, because only digits are allowed (but not e.g. "."); and most likely, the resulting number is too big to be converted to a 32bit integer, so "cast (... ) as int" might fail where it shouldn't. For that reason, it's not much of a WTF IMO.
Admin
I don't get it...this guy was trying to add a T-SQL function into Oracle?
Admin
Why should PHP be faster than, say, T-SQL or PL/SQL? Just because an interpreter is running in the database doesn't necessarily mean that it's slower.
Admin
Everyone is a little bit wrong here:
Andy shouldn't be using IsNumeric without any further processing because, as others have commented, it will return true for numeric symbols such as a decimal point. However, I'm going to give Andy the benefit of the doubt and assume that his revised function handled these cases. After all, the article specifically says that he researched the IsNumeric function and it's behaviour in this regard is perfectly well documented.
The manager is wrong for thinking that a piece of code has to be written in the same way to function the same way. In any programming language there are a myriad of ways to code exactly the same function. Only a clueless manager would assume that two pieces of code have to perform exactly the same steps in order to perform the same function.
Personally speaking, the manager scores highest on my WTF meter.
Admin
The real WTF is the manager used the phrase, "think outside the box."
Admin
The manager is totally right. The only way to test these kinds of mass code changes is through automated scripts that compare outputs. If there is ANY change in behaviour, even if it's to fix a bug, it can make automated testing infeasible. Noting the defect and fixing it after the conversion would be a better approach. Sometimes you need to step back and look at the bigger picture...
Admin
On the other hand, it's trivially easy to formaly prove that program B is an 1:1 translation of program A (exactly the same steps in order to perform the same function), while it is generally speaking difficult to impossible to prove that a differently written program B gives the same result like program A. To be on the safe side, requiring an 1:1 translation doesn't seem unreasonable to me.
Admin
What is the WTF?
Unless the system is under test, their best bet is to transliterate the semantics of one system to the other. Other parts of the system may rely on that idiosyncratic behavior.
Admin
That's cute. I'll bet you store zip codes as integers, too.
Admin
Admin
Admin
TRWTF is the choice of language.
Admin
Admin
Regardless whether the manager in this case was right or not: your manager is typically not interested in technical details.
If it's a technical decision, then it needs to be made by you, because you are the assigned engineer. If you are not prepared to take responsibility for the change yourself you should skip it. Asking for permission just tells your boss that you are not confident that your approach is right. In all likelihood he'll reject your proposal and will think of you as incompetent.
Admin
I agree not a WTF, the programmer is TRWTF, etc, but...surely that while loop can't be significantly faster than
? Can it?
Admin
It's a good thing they're checking to make sure "@CheckDigit is null" in the Catch block. They probably wanted to implement something like "IF TRUE", but TSQL doesn't support booleans so they were stuck with the equivalent.
Admin
Admin
IsNumeric() would allow currency symbols, negative signs, decimal points, etc - all of which can NOT be rendered as a bar code. The manager is right that the implementation would be different. The "Andy" in the story needs to STFU and not assume he is the smartest person in IT.
Admin
TRWTF is that the code was well documented to begin with.
Admin
So can PL/SQL, although it would be wise to format the code, such as given in this example:
l.
Admin
Right - it was coded correctly in T-SQL by the previous developer(s). It's the new Oracle developer causing problems by unnecessarily extending his "expertise". If he stuck to his directive and ported the function to oracle, he wouldn't be sidetracked with trying to throw somebody else under the bus. The real WTF is the n00b dev wanting to make a name for themselves.
Admin