• (cs) in reply to C-Octothorpe
    C-Octothorpe:
    string myString = "this is a string"; return (string)myString.ToString() as string;

    WTF?! It's a string already!!

    Yes, but isn't it better to really be sure?

  • Carl (unregistered)
    Nothing fully worked, but things half-worked half the time. The big rewrite yielded exactly the same thing, but in VB.NET.
    But that's what you should expect when your system has no written specs, because in that case, the old system is the specification.
  • trtrwtf (unregistered) in reply to Marvin the Martian
    Marvin the Martian:
    "Classic ASP"?

    Pff... I'm getting old. What's next? "Canonical Ruby-on-rails"? "Ancient Python"?

    I was just called "old-school" this morning because I asked my boss to put perl or python onto the svn server so I can autogenerate the documents on a commit. Perl, I could sort of understand, but python? Yeah, python's old-school to him...

  • (cs) in reply to Aether
    Aether:
    WC:
    If you're going to Doubleize something, you have to do it twice. Duh.
    Wouldn't that Quadrupleize it?
    Didn't you read the article? See for yourself:
    From TFA:
    Nothing fully worked, but things half-worked half the time.
    Obviously they need to quadrupleize it.
  • (cs) in reply to Carl
    Carl:
    Nothing fully worked, but things half-worked half the time. The big rewrite yielded exactly the same thing, but in VB.NET.
    But that's what you should expect when your system has no written specs, because in that case, the old system is the specification.

    Isn't it alwasy fun trying to determine whether or not a bug you discovered was intentional or just a bug and will the business users be pleased or pissed if you actually implement the logic correctly...

    I had this happen to me recently and luckily they didn't even know [broken feature which never worked] even existed.

  • trtrwtf (unregistered) in reply to Jay
    Jay:
    trtrwtf:
    You know, I've never known a joke that was improved by arguing over whether it was funny or not.

    If you tell a joke and the other person doesn't laugh, and then you explain to them why it's funny, logically, now they should laugh. Retroactively.

    Does that ever work for you? Anyway, they're not explaining the joke, they're arguing about whether it was funny. Pure Td, if you ask me.

  • Non-A (unregistered) in reply to trtrwtf
    trtrwtf:
    Marvin the Martian:
    "Classic ASP"?

    Pff... I'm getting old. What's next? "Canonical Ruby-on-rails"? "Ancient Python"?

    I was just called "old-school" this morning because I asked my boss to put perl or python onto the svn server so I can autogenerate the documents on a commit. Perl, I could sort of understand, but python? Yeah, python's old-school to him...

    Don't worry, your boss' test for old-school went thusly:

    if (isOldSchool("perl") || isOldSchool("python")) {
        return "old-school";
    } else {
        return "new-school";
    }

    So we really have no way of knowing if Python was old-school to him.

  • (cs) in reply to K
    K:
    Bonus:

    Most people don't know that, but the numeric separator ("." in the US) is a "," instead in Germany. Oh how much fun this is!

    Actually, quite a few applications do not know that the meaning of , and . is swapped in German (and in Danish by the way), that's why I always set my computers to use US numeric system . for decimal point as opposed to , as is the 'official' Danish way....

    Yazeran

    Plan: To go to Mars one day with a hammer.

  • ted (unregistered) in reply to Nagesh
    Nagesh:
    Can someone plz post Java™ code of equivalency for this?
    Why don't you go away and die of diahreea poisoning?
  • Meep (unregistered) in reply to trtrwtf
    trtrwtf:
    Marvin the Martian:
    "Classic ASP"?

    Pff... I'm getting old. What's next? "Canonical Ruby-on-rails"? "Ancient Python"?

    I was just called "old-school" this morning because I asked my boss to put perl or python onto the svn server so I can autogenerate the documents on a commit. Perl, I could sort of understand, but python? Yeah, python's old-school to him...

    Python was first released in '94, is not old school. Perl is getting there, released in '87. Ruby, by comparison, first became public in '93.

    "Old-school" would be your centralized version control system that is an API compatible remake of CVS, which is itself just RCS on life support, which in turn is the bastard child of SCCS, developed in 1972. They've glommed new features on, but there are probably projects out there that have migrated from SCCS all the way to SVN.

  • trollsolo (unregistered)

    The true WTF is that they should have used .NET regex:

    ^([+-]?[0-9.]*

  • Paul (unregistered) in reply to Meep

    SCCS to SVN then onwards. Oh yes, oh yes.

  • Paul (unregistered) in reply to Meep

    SCCS to SVN then onwards. Oh yes, oh yes.

  • John (unregistered)

    "Turns strings into numbers" is incorrect, at least I think it is after looking for 2 minutes.

    Doesn't the line "Mid(trimmedStr, 1, k - 1)" take a number up to the first non-number. So doubilize( 37yes ) becomes 37.0

    Also the TWTF is that if statement with the not, orelse, wazzup, etc.

  • Babak (unregistered) in reply to Niten

    Also double your billable hours :-)

  • (cs) in reply to ted
    ted:
    Nagesh:
    Can someone plz post Java™ code of equivalency for this?
    Why don't you go away and die of diahreea poisoning?

    Sure it's not just hot coffee?

  • (cs) in reply to Severity One
    Severity One:
    airdrik:
    TRWTF is a language which needs two versions of and/or: one with short-cut logic built-in and one without.
    You mean, like Java? This
        if( x!=0 & 4/x>1 )
    is perfectly valid Java. It will also throw an exception if x=0.

    Possibly, there are instances where this comes in useful, but I can't think of any.

    Yep, I was about to ask the same question. The OP could also be complaining about C, C++, Perl, Python, Eiffel, Bash, PHP (TRWTF is somebody creating PHP after we see what happened to ASP), or a plentora of other languages.

    About it being useful... I guess it is not, or at least should not be useful. The reason that constuc is alowed is to keep the language simple (with the minimum amount of rules), and that we need both binary and logical AND, and logical should short-cut.

  • (cs) in reply to ratis
    ratis:
    SeiginoRaikou:
    .NET's Double.Parse throws an exception if the string is invalid, and Double.TryParse just catches that exception. Exception handling is way slower in .NET than just detecting failure like this is trying to do. Our company has something similar (and much better) in our internal code library as an extension method. Basically (in C#):
    if(myString.IsNumeric())
        double d = Double.Parse(myString);
    
    is much better than Double.TryParse and also doesn't rely on a goofy out parameter.

    TryParse() does not throw and catch exceptions internally. It works completely without exceptions. Your IsNumeric() just wastes time.

    Dim d As Double = 0
    Dim tim1 As Long = DateTime.Now.Ticks
    Double.TryParse("aaa", d)
    Dim tim2 As Long = DateTime.Now.Ticks
    Try
        d = Double.Parse("aaa")
    Catch
    End Try
    Dim tim3 As Long = DateTime.Now.Ticks
    System.Diagnostics.Debug.WriteLine("" & (tim2 - tim1))
    System.Diagnostics.Debug.WriteLine("" & (tim3 - tim2))
    

    TRWTF is not using System.Diagnostics.Stopwatch.

  • (cs) in reply to trollsolo
    trollsolo:
    The true WTF is that they should have used .NET regex:

    ^([+-]?[0-9.]*

    I didn't know "0.0.0.0.0.0" was a valid number... And that 1.05e-3 wasn't.

  • (cs) in reply to The_Assimilator
    The_Assimilator:
    TRWTF is not using System.Diagnostics.Stopwatch.
    Check that out! Thanks. I learned something new today. :)
  • ted (unregistered) in reply to ted
    ted:
    Nagesh:
    Can someone plz post Java™ code of equivalency for this?
    Why don't you go away and die of diahreea poisoning?
    Now that guy, there, is not me. I think that is the real ted, or maybe a different impostor. I am not the real ted.

    Just so there is no confusion.

  • Double Vader (unregistered) in reply to boog
    boog:
    Aether:
    WC:
    If you're going to Doubleize something, you have to do it twice. Duh.
    Wouldn't that Quadrupleize it?
    Obviously they need to quadrupleize it.
    I am doubling the size. Pray I do not double any further.
  • (cs)

    I AM SEEING DOUBLE!!

  • (cs) in reply to Matt Westwood
    Matt Westwood:
    ted:
    Nagesh:
    Can someone plz post Java™ code of equivalency for this?
    Why don't you go away and die of diahreea poisoning?

    Sure it's not just hot coffee?

    Sure doesn't taste like coffee...

  • Obsessive Comment Reader (unregistered) in reply to Double Vader
    Double Vader:
    boog:
    Aether:
    WC:
    If you're going to Doubleize something, you have to do it twice. Duh.
    Wouldn't that Quadrupleize it?
    Obviously they need to quadrupleize it.
    I am doubling the size. Pray I do not double any further.
    I get these comments sent to my email automatically, and this one got sent to spam :(
  • Anon (unregistered) in reply to Obsessive Comment Reader
    Obsessive Comment Reader:
    Double Vader:
    boog:
    Aether:
    WC:
    If you're going to Doubleize something, you have to do it twice. Duh.
    Wouldn't that Quadrupleize it?
    Obviously they need to quadrupleize it.
    I am doubling the size. Pray I do not double any further.
    I get these comments sent to my email automatically, and this one got sent to spam :(
    Wait a minute - you get all comments sent to your email or just Darth Vader one's?

    Either way - WTF?

  • Obsessive Comment Reader (unregistered) in reply to Anon
    Anon:
    Obsessive Comment Reader:
    Double Vader:
    boog:
    Aether:
    WC:
    If you're going to Doubleize something, you have to do it twice. Duh.
    Wouldn't that Quadrupleize it?
    Obviously they need to quadrupleize it.
    I am doubling the size. Pray I do not double any further.
    I get these comments sent to my email automatically, and this one got sent to spam :(
    Wait a minute - you get all comments sent to your email or just Darth Vader one's?

    Either way - WTF?

    Reading comments gets blocked by my company.

    'nuff said.

  • Anon (unregistered) in reply to Obsessive Comment Reader
    Obsessive Comment Reader:
    Anon:
    Obsessive Comment Reader:
    Double Vader:
    boog:
    Aether:
    WC:
    If you're going to Doubleize something, you have to do it twice. Duh.
    Wouldn't that Quadrupleize it?
    Obviously they need to quadrupleize it.
    I am doubling the size. Pray I do not double any further.
    I get these comments sent to my email automatically, and this one got sent to spam :(
    Wait a minute - you get all comments sent to your email or just Darth Vader one's?

    Either way - WTF?

    Reading comments gets blocked by my company.

    'nuff said.

    Awesome - so instead of letting you look at comments, you get emailed every single one causing unnecessary server use and then come one here to talk to me about it wasting time.

  • Pepsi (unregistered) in reply to Meep
    Meep:
    Geoff:
    You'd think in some course somewhere along the line programing instruction could spend a day or so the correct patterns for this activity.

    You can lecture people on the right way, but they won't internalize it until they've screwed up and fixed it.

    +1

  • (cs) in reply to Obsessive Comment Reader
    Obsessive Comment Reader:
    Anon:
    Obsessive Comment Reader:
    Double Vader:
    boog:
    Aether:
    WC:
    If you're going to Doubleize something, you have to do it twice. Duh.
    Wouldn't that Quadrupleize it?
    Obviously they need to quadrupleize it.
    I am doubling the size. Pray I do not double any further.
    I get these comments sent to my email automatically, and this one got sent to spam :(
    Wait a minute - you get all comments sent to your email or just Darth Vader one's?

    Either way - WTF?

    Reading comments gets blocked by my company.

    'nuff said.

    How'd you post to this site then? Do you have some sort of intranet setup that has Unix-style permissions, where you only have write, and not read? That'd be a pretty entertaining submission.

  • Anon (unregistered) in reply to Power Troll
    Power Troll:
    Obsessive Comment Reader:
    Anon:
    Obsessive Comment Reader:
    Double Vader:
    boog:
    Aether:
    WC:
    If you're going to Doubleize something, you have to do it twice. Duh.
    Wouldn't that Quadrupleize it?
    Obviously they need to quadrupleize it.
    I am doubling the size. Pray I do not double any further.
    I get these comments sent to my email automatically, and this one got sent to spam :(
    Wait a minute - you get all comments sent to your email or just Darth Vader one's?

    Either way - WTF?

    Reading comments gets blocked by my company.

    'nuff said.

    How'd you post to this site then? Do you have some sort of intranet setup that has Unix-style permissions, where you only have write, and not read? That'd be a pretty entertaining submission.

    More likely he can get to the Post Comments-page but, not the View Comments page.

    Or he can reply to comments by e-mail.

  • jb (unregistered) in reply to Severity One
    Severity One:
    airdrik:
    TRWTF is a language which needs two versions of and/or: one with short-cut logic built-in and one without.
    You mean, like Java? This
        if( x!=0 & 4/x>1 )
    is perfectly valid Java. It will also throw an exception if x=0.

    Possibly, there are instances where this comes in useful, but I can't think of any.

    you can't think of any instances where it is useful to have both logical and bitwise 'AND' as programming constructs?

    this was about the only comment in this thread which looked interesting.. so I'm curious to actually understand what you are meaning here.

  • Jimmy (unregistered) in reply to Geoff
    Geoff:
    I would imagine conversion of strings to some time integer value, hopefully not floats for currency dealings, is about the most common input gathering activity in programing business apps. Luckily there exist clean, reasonably safe, easy ways to do this. - Or you can do this way.

    You'd think in some course somewhere along the line programing instruction could spend a day or so the correct patterns for this activity.

    Yah...It seems most WTFs are cases of reinventing wheels to be less efficient

  • (cs) in reply to Yazeran
    Yazeran:
    K:
    Bonus:

    Most people don't know that, but the numeric separator ("." in the US) is a "," instead in Germany. Oh how much fun this is!

    Actually, quite a few applications do not know that the meaning of , and . is swapped in German (and in Danish by the way), that's why I always set my computers to use US numeric system . for decimal point as opposed to , as is the 'official' Danish way....

    Yazeran

    Which brokes the other half of applications, especially MS Office doesn't like having set decimal separator to point when the locale default is comma (e.g. if you have set word as outlook editor -- which is of course the real wtf by itself -- it will complain every time you want to compose message).

  • Sauze (unregistered) in reply to frits
    frits:
    powerlord:
    frits:
    At least they didn't use Val().

    Yes, don't use Val. It's much better to use Double.Parse.

    Where's the funny? Val() is a commonly misused VB-specific function. Double.Parse() is probably an acceptable solution.

    Surely you've been here long enough to know that not everyone does funnies, Fritz...

  • as;oei (unregistered) in reply to trtrwtf
    trtrwtf:
    frits:
    Anon:
    frits:
    powerlord:
    frits:
    At least they didn't use Val().

    Yes, don't use Val. It's much better to use Double.Parse.

    Where's the funny? Val() is a commonly misused VB-specific function. Double.Parse() is probably an acceptable solution.

    I can't get any work done with all this WHOOSH!

    Most likely on your part, unless offering the obvious solution in a sarcastic way passes for funny now.

    You know, I've never known a joke that was improved by arguing over whether it was funny or not.

    Gold!!! Best joke ever!!

  • You don't say!!! (unregistered) in reply to Anon
    Anon:
    I think that OrElse, AndAlso are VB's way of introducing the short circuit behaviour of C's (and others) || and && operators.

    In C,

    if (1 || f(x)) { ... }

    and

    if (0 && g(y)) { ... }

    will result in neither f(x) nor g(y) being evaluated.

    I think many are suggesting that Lazy evaluation should be the norm. VB's take on it is that you may be calling functions that have side effects, adn lazy evaluation stops this. Of course the real problem is that people call functions with side-effects from within conditional statements.

    I'm no big fan of VB, but I think allowing the programmer to choose Lazy Evaluation or Full Evaluation is well intended. Unfortunately, the road to Programming Hell is paved with VB's good intentions!

  • Juryie (unregistered) in reply to Yazeran
    Yazeran:
    K:
    Bonus:

    Most people don't know that, but the numeric separator ("." in the US) is a "," instead in Germany. Oh how much fun this is!

    Actually, quite a few applications do not know that the meaning of , and . is swapped in German (and in Danish by the way), that's why I always set my computers to use US numeric system . for decimal point as opposed to , as is the 'official' Danish way....

    Yazeran

    Plan: To go to Mars one day with a hammer.

    Has anyone here heard on internationalisation? And can they give me a quick primer? (Could be wrong, but I think much of Europe uses , and . the opposite way to the English-Speaking world - or perhaps the ESW uses it the opposite way to much of Europs - I forget)

  • Bu Wai.... (unregistered) in reply to Anon
    Anon:
    Obsessive Comment Reader:
    Anon:
    Obsessive Comment Reader:
    Double Vader:
    boog:
    Aether:
    WC:
    If you're going to Doubleize something, you have to do it twice. Duh.
    Wouldn't that Quadrupleize it?
    Obviously they need to quadrupleize it.
    I am doubling the size. Pray I do not double any further.
    I get these comments sent to my email automatically, and this one got sent to spam :(
    Wait a minute - you get all comments sent to your email or just Darth Vader one's?

    Either way - WTF?

    Reading comments gets blocked by my company.

    'nuff said.

    Awesome - so instead of letting you look at comments, you get emailed every single one causing unnecessary server use and then come one here to talk to me about it wasting time.
    If ReadingThemGetsBlocked Then HowTheHellDoYouManageToPost EndIf

  • (cs) in reply to Marvin the Martian
    Marvin the Martian:
    "Classic ASP"?

    Pff... I'm getting old. What's next? "Canonical Ruby-on-rails"? "Ancient Python"?

    You need those to counterbalance "Advanced BASIC".

  • Constant Coder (unregistered) in reply to boog
    boog:
    Severity One:
    You mean, like Java? This
        if( x!=0 & 4/x>1 )
    is perfectly valid Java. It will also throw an exception if x=0.

    Possibly, there are instances where this comes in useful, but I can't think of any.

    Isn't & a bitwise operator in Java? I don't think it was ever intended to be used as a non-short-cut boolean "AND".

    Or were you joking?

    In BASIC, "AND", "OR", "XOR" etc are bitwise operators. They are used as non-short-cut Boolean "AND", "OR" etc.

    Exhaustive evaluation allowed BASIC to re-order Boolean expressions. Generally this means that BASIC does not have to be hand-optimized to get good performance out of complex logic.

    The PASCAL I used was able to optimize better than either C or BASIC, because by design it did guarantee the representation of Booleans, the order of evaluation, or exhaustive evaluation.

  • (cs)

    My favorite line avoids calling Trim; instead using two calls to do the same thing:

    trimmedStr = LTrim(RTrim(StrVal))

    Whoever wrote this must have been being paid per function call.

  • Lock Stock (unregistered) in reply to Coyne
    Coyne:
    My favorite line avoids calling Trim; instead using two calls to do the same thing:
    trimmedStr = LTrim(RTrim(StrVal))
    Whoever wrote this must have been being paid per function call.
    "Left Foot, Right Foot: your body will follow - they call it walking!"
  • (cs) in reply to Mcoder
    Mcoder:
    trollsolo:
    The true WTF is that they should have used .NET regex: ^([+-]?[0-9.]*
    I didn't know "0.0.0.0.0.0" was a valid number... And that 1.05e-3 wasn't.
    You obviously didn't look at the original source code closely enough then. Though the regex doesn't match the original source either.

    In fact 1.05e-3 is a valid number (according to Doubleize), equal to 1.05. Also equal to 1.05WTF35167. While 0.0.0.0.0.0 is supposedly valid, I don't know whether the CDbl call will choke on it.

    Replicating the precise functionality of Doubleize is a lot harder than most of the suggestions posted. However, if you have an operational requirement to do things like converting 126TEXT754 into 126.0000, needless to say you have bigger problems than getting the conversion function right.

  • (cs) in reply to Jimmy
    Jimmy:
    Geoff:
    I would imagine conversion of strings to some time integer value, hopefully not floats for currency dealings, is about the most common input gathering activity in programing business apps. Luckily there exist clean, reasonably safe, easy ways to do this. - Or you can do this way.

    You'd think in some course somewhere along the line programing instruction could spend a day or so the correct patterns for this activity.

    Yah...It seems most WTFs are cases of reinventing wheels to be less efficient

    Actually, I've thought about this ... I have an idea what might have happened here.

    A lot of programming courses try to teach the programmer to think in a logical way. And one of the exercises in the elementary course is: "Write a function to convert a generic input string to a number. It will be expected to take any random agglomeration of digits and letters and make sense of it ..." and so on. Having done this assignment, your student gets 5/10 for it. "Oh good, that's a pass!" he says. "I must save that in my Little Black Book of my Best Programs Ever!"

    The next week, the proto-programmer gets an internship. His boss says: "We might get people typing stuff in this box which isn't numbers. The way it's currently programmed, that would make it break. You've done Data Entry 101 - I'd like you to sort this out for me." And proto-programmer enthusiastically barks: "Aye aye sir!" and proudly pastes in place the abovementioned.

  • Grey (unregistered) in reply to dohpaz42

    TRWTF is using floating point anywhere except science calculations, i.e. 3D geometry.

  • (cs) in reply to SeiginoRaikou
    SeiginoRaikou:
    HP PhaserJet:
    Maybe I was confused, the function doesn't look like
    if(myString.IsNumeric())
        double d = Double.Parse(myString);
    
    - the use case does.

    But then aren't you parsing the double twice? One pass to validate it for parsing and then another to actually parse it.

    Was showing how we do it- the use case is a little different from the WTF, but taking 2 passes on the string is still faster than catching a FormatException from Double.Parse

    Just to confirm what others have already answered, I just went to the decompiled code of the double.TryParse, and to me it seems like a sane use of basic if-else/while logic, not sexy but efficient looking, and without exception handling.

    Actually TryParse is the basic parsing method that returns a boolean. Parse juste uses TryParse and throws a FormatExeption when that boolean is false.

    Also, if you think you can write a 5 line method that is more efficient to parse a string than the one written by the developpers of the framework you use, maybe you should realize you're on the road to WTF.

  • Dave (unregistered) in reply to K

    Extra bonus:

    Most people don't know that, but the comma ("," in the US) is a ";" instead in Germany.

    (according to Excel)

  • Someone who can't be bothered to login from work (unregistered) in reply to Marvin the Martian
    Marvin the Martian:
    "Classic ASP"?

    Pff... I'm getting old. What's next? "Canonical Ruby-on-rails"? "Ancient Python"?

    "Classic ASP" is what people have been referring to non-ASP.NET as for ages.

  • Someone who can't be bothered to login from work (unregistered) in reply to Yazeran
    Yazeran:
    K:
    Bonus:

    Most people don't know that, but the numeric separator ("." in the US) is a "," instead in Germany. Oh how much fun this is!

    Actually, quite a few applications do not know that the meaning of , and . is swapped in German (and in Danish by the way), that's why I always set my computers to use US numeric system . for decimal point as opposed to , as is the 'official' Danish way....

    Yazeran

    Plan: To go to Mars one day with a hammer.

    Fortunately .NET does know this. Although it still requires the developer to write their code in such a way as to to take advantage of this.

    In the case of Decimal.Parse() or Decimal.TryParse() it requires you to use an overload that takes an IFormatProvider that contains the culture specific formatting rules - which if you're lucky will be CultureInfo.CurrentCulture or CultureInfo.CurrentUICulture, otherwise you need to use CultureInfo.GetCultureInfoByIetfLanguageTag()to grab it.

Leave a comment on “Doubleizing”

Log In or post as a guest

Replying to comment #:

« Return to Article