• Anders Hesselbom (unregistered) in reply to ChiefCrazyTalk

    Is this for real? You're killing me!!! By the way, isn't strings just yet another "beautiful" way of presenting byte arrays? Remove the unnecessary floats, strings and booleans!<o:p></o:p>

  • (cs) in reply to Grovesy
    Anonymous:

      //throw exception if bad input
      if (field.Length == 0 | entity.Length == 0) return "-1";

    Nice exception! And there was me thinking that in this situation a System.ArgumentOutOfRange exception would have been more appropriate



    The comment probably should have been
    //throw major WTF if bad input (hey, if you cant bother to give us real inputs, we're not going to give you real exceptions) 

  • (cs)

    Enough with the anonymyzing already. If it's really that bad, just run it through a formatter (change brace style) and rename the variables by pre-pending "paula" to each.


  • Demaestro (unregistered)

    Maybe I am missing something here but doesn't this code also assume that it is base 100.

    What if I want to do seconds to minutes? Or minuntes to hours?

  • elmegil (unregistered)

    Ok, so the code sucks.

    And it doesn't take into account some obvious cases ($0.00 is mentioned above).

    But this sounds like you are presuming that money is always done in floating point, when in fact, using fixed point decimal (ok, so this doesn't really do that either), and representing the numbers as integers, is generally much simpler.  Depending on your integer math implementation (does it round?) you can avoid things like "$0.9999999999999999999" etc.

    There seem to be plenty of reasons to dismiss this code as WTF without attacking the idea of integer money.

  • Bremac (unregistered) in reply to jmeyer43

    Well, it works - if either is equal to 0, the OR makes the output 1, so it's true. Now XOR, that would have been more interesting, and maybe even a new enterprise standard. (And a real WTF - "What do you mean, it causes errors if they're both equal to 0?")

  • Brad (unregistered)

        In Java, try this:

    System.out.println(2.00 - 1.10);
        and see how much change you get back from your two dollars.


  • (cs) in reply to mrprogguy
    mrprogguy:
    Yes, doing math in cents for money (other than for things like corporate profits and government budgets) eliminates lots of round-off errors.  It's actually much better for calculation of sales tax and that sort of thing.  Don't sneer at money math in cents--it's what's for dinner!


    I think you mean doing money math in decimal instead of binary. Floating point has nothing to do with it.

    There are a number of standards (SOX and otherwise) that explicitly specify what precision to carry for various operators.
  • Mike MacDonald (unregistered) in reply to Jesus Christ
    Anonymous:
    <font color="#ff0000" face="Verdana" size="6">>:3</font>


    It's a LION! GET IN THE CAR!
  • (cs) in reply to Simon
    Anonymous:
    Yes, I am the Simon that submitted this.  It looks like Alex got confused when anonymizing the part at the end that actually does the "math" (I did too, at first).  This is the actual algorithm:

    Start with the string "1".
    Append "0" to that string the appropriate number of times for the places from the metadata.
    Convert that resulting string to a number, divide the parameter by it, convert that floating-point number back to a string, then return that float-in-a-string.


    Wow... alot different than the code Alex had (still has even).... Also... Alex.... It'd be nice if you didn't edit your posts after you post them. It would work if you added to the post, re-pasteing the "fixed" code... Now, most of the posters look like idiots (especially me) because they were commenting on the original post...

    Care to post the original in AS CLOSE AS POSSIBLE form?

    Seriously, today's mis-hap has me thinking that the majority of comments people submit are actually comments on Alex's not-so-succesful conversion between languages.... Ouch.
  • (cs) in reply to smbell
    smbell:

    Once again the comments approach the level of WTF as the code example.  Storing numbers and decimal when dealing with money is unacceptable due to the imprecise nature of decimal numbers.  They are merely an approximation, not an exact value.

    This obscures the fact that most modern languages (.NET included) have support for accurate decimal number representation in the form of some math library or class (I think in .NET it is BigDecimal?).  That is 'the real WTF'.


    What are you talking about? What number system do you suggest for working with money if not decimal?

    The real WTF is that people don't know the difference between decimal and floating point.
  • (cs) in reply to Simon

    Anonymous:
    Yes, I am the Simon that submitted this.  It looks like Alex got confused when anonymizing the part at the end that actually does the "math" (I did too, at first).  This is the actual algorithm:

    Start with the string "1".
    Append "0" to that string the appropriate number of times for the places from the metadata.
    Convert that resulting string to a number, divide the parameter by it, convert that floating-point number back to a string, then return that float-in-a-string.

    Yeah, never user 10^n when you can use a for loop, Stringbuilder, and a type conversion.

    --Rank

  • (cs) in reply to channer
    channer:
    I just love the enterprisey naming conventions of the private method:

    _getDecimalPlaceForField

    wtf? who starts a method name with an underscore ? - not forgetting the lack of pascal casing

    That's just the Perl naming convention to indicate a private method.

  • (cs) in reply to GoatCheez
    GoatCheez:
    Anonymous:
    Yes, I am the Simon that submitted this.  It looks like Alex got confused when anonymizing the part at the end that actually does the "math" (I did too, at first).  This is the actual algorithm:

    Start with the string "1".
    Append "0" to that string the appropriate number of times for the places from the metadata.
    Convert that resulting string to a number, divide the parameter by it, convert that floating-point number back to a string, then return that float-in-a-string.


    Wow... alot different than the code Alex had (still has even).... Also... Alex.... It'd be nice if you didn't edit your posts after you post them. It would work if you added to the post, re-pasteing the "fixed" code... Now, most of the posters look like idiots (especially me) because they were commenting on the original post...

    Care to post the original in AS CLOSE AS POSSIBLE form?

    Seriously, today's mis-hap has me thinking that the majority of comments people submit are actually comments on Alex's not-so-succesful conversion between languages.... Ouch.


    I have to agree on this one.  Take for example this post which originally missed out the crucial last line, making (mainly me) looking stupid for saying it wasn't a massive WTF
  • Anonymous (unregistered)

    You know, computers use binary. Wouldn't it be much better to get rid of all datatypes except for booleans?

  • kbiel (unregistered) in reply to Anonymous
    Anonymous:
    You know, computers use binary. Wouldn't it be much better to get rid of all datatypes except for booleans?


    yes,yes,yes,yes
  • Ishai (unregistered) in reply to WeatherGod

    WeatherGod:
    But, what if the user wanted $0.00 to show up for 0 cents?  Does this mean I have to program an if statement to change "0" to "0.00" whereever I want that "beautification"?

    Also, would this really work in the first place anyway?

    well, I tried to compile it in visual studio .net, but it crashed with a "you are too dumb" exception.

    I wonder how the CEF guys managed to compile it.

    Captcha? wtf is captcha? and why is mine tps?

  • (cs)

    To those of you who are arguing storing floating point numbers as integers is a good thing if absolute precision is required, I'd like to say two things:
    1. You are right
    2. This is not the way to do it

    To the designers of the CEF, I present: the System.Decimal type. It does what they want, and the best part is you can get a string representation using the normal ToString or String.Format methods that every .Net programmer should know.

    EDIT: It would appear I was beaten to the punch. Or "ninja'd", as I believe the proper term is. :P
    EDIT2: Although I get bonus-points for linking to the new MSDN2 site instead of the old .Net 1.1 MSDN docs. ;)

  • (cs) in reply to Carnildo
    Carnildo:
    channer:
    I just love the enterprisey naming conventions of the private method:

    _getDecimalPlaceForField

    wtf? who starts a method name with an underscore ? - not forgetting the lack of pascal casing

    That's just the Perl naming convention to indicate a private method.




    wtf is it doing in c# code then? or is this another anonymization?

  • (cs)

    The more I think about this, the more I stunned I am. Whoever came up with this crap should be fired and banned from development forever.

    If I were told I needed to use this I would have one very short word in reply: no....


    On another note: gotta love Community Server v2.0! Firebug reports 1811 errrors and counting! What, two errors per key click, what's wrong with that.....

    Oooh now we're up to 2177 Errors.

    now 2285, 2297, 2319

    -me




  • (cs) in reply to Jon W
    Jon W:
    Enough with the anonymyzing already. If it's really that bad, just run it through a formatter (change brace style) and rename the variables by pre-pending "paula" to each.


    Yeah, seriously Alex, this anonymyzing is getting bad. Change the variables to "string1", "string2", "int1", "int2", tweak the namespaces/classnames slightly and be done with it....

    -me
  • (cs) in reply to merreborn
    merreborn:
    Jesus Christ:
    <font color="#ff0000" face="Verdana" size="6">>:3</font>



    God damnit, we've been 4chan'd.  Get in the car.

    THIS is a real WTF (... sandwich. It's made of 4chan, lion, wft code and getting into.)
  • me (unregistered) in reply to viraptor
    viraptor:
    merreborn:
    Jesus Christ:
    <font color="#ff0000" face="Verdana" size="6">>:3</font>



    God damnit, we've been 4chan'd.  Get in the car.

    THIS is a real WTF (... sandwich. It's made of 4chan, lion, wft code and getting into.)



    I'm sorry, I don't speak jibberish
  • (cs) in reply to R.Flowers

    This puts me in mind of a magnificent application I had to support for many years, which took a real world approach to on-hand stock.
    You see, there can't possibly be a negative number of things in stock, so the system wouldn't let you issue more than it had. This caused a problem of significant size if the data-entry person recording receipts hadn't yet placed items in stock when you were issuing them.
    Worse than that, issues beyond what you had would be possible if they were in stock in another location...this meant that not only were you out of sync at your own location, but at other locations too.
    Fortunately, the system had some quite good stock-taking options.

  • JL (unregistered) in reply to channer
    channer:
    Carnildo:
    channer:
    I just love the enterprisey naming conventions of the private method:

    _getDecimalPlaceForField

    wtf? who starts a method name with an underscore ? - not forgetting the lack of pascal casing

    That's just the Perl naming convention to indicate a private method.

    wtf is it doing in c# code then? or is this another anonymization?
    It's a common practice outside of Perl, too, to prepend underscores to private members.  It's the de facto standard in Python and boo, and I've seen it used in Java and C++ code as well, so it's not a stretch to see it in C#.

  • (cs) in reply to JL
    Anonymous:
    channer:
    Carnildo:
    channer:
    I just love the enterprisey naming conventions of the private method:

    _getDecimalPlaceForField

    wtf? who starts a method name with an underscore ? - not forgetting the lack of pascal casing

    That's just the Perl naming convention to indicate a private method.

    wtf is it doing in c# code then? or is this another anonymization?
    It's a common practice outside of Perl, too, to prepend underscores to private members.  It's the de facto standard in Python and boo, and I've seen it used in Java and C++ code as well, so it's not a stretch to see it in C#.


    sure - to members, but methods?

  • (cs) in reply to its me

    its me:
    Jon W:
    Enough with the anonymyzing already. If it's really that bad, just run it through a formatter (change brace style) and rename the variables by pre-pending "paula" to each.


    Yeah, seriously Alex, this anonymyzing is getting bad. Change the variables to "string1", "string2", "int1", "int2", tweak the namespaces/classnames slightly and be done with it....

    -me

    Sure, no problem. But you guys got my back when I get sued for exposing proprietary trade secrets, copyright violation, libel, defamation, DMCA, causing someone to lose his job, etc., right? Then again, who could possibly recognize their own work if some one went so far as to change a word or two? Riiiiggghhhttt .....

    Come one guys, if you're thinking "OMFGWTFBBQ!! He used a | instead of a ||" when you see the article, you need to go back and read it again. You missed the part where the CEF system uses only numbers and strings and requires a database call to convert integers to decimals.

  • (cs) in reply to A Nonny moose
    Anonymous:

    Anonymous:
    I wonder what their system does for dates?

    They don't, because software engineers can't get any!

    rimshot!

    He's here all week, folks! Tip your waitress!

  • Lord of the 'Brillant' Bean (unregistered)

    wouldn't it be more enterprisey, if we had a table called called TBL_T_NUMBER that looked like this:


    COLUMN_INT                    COLUMN_DECIMAL                       COLUMN_VALUE
    -------------------------------------------------------------------------------------------------
    75                                             1                                                             000075
    75                                             2                                                             .....
    .......

    and so on. Then instead of calling the function


    public string SetDecimalPlace(int number, string field, string entity)


    , the user needs to create a xml file

    <setdecimal>
    <number>75</number>
    <field>..</field>
    <entity>....</entity>
    </setdecimal>

    The enterprise system will parse the xml file, get the correct value from the database and display it.

    Its foolproof!

  • Lord of the 'Brillant' Bean (unregistered) in reply to Lord of the 'Brillant' Bean

    oh fuck. the forum software screwed the above post. lets do it again

    wouldn't it be more enterprisey, if we had a table called called TBL_T_NUMBER that stored all possible combinations of numbers,decimal places and the result.

    Then instead of calling the setdeicmalplace() function<font face="Lucida Console" size="2"></font>

    , the user needs to create a xml file


    <setdecimal>
    <number>75</number>
    <field>..</field>
    <entity>....</entity>
    </setdecimal>


    The enterprise system will parse the xml file, get the correct value from the database and display it.

    Its foolproof!

  • Bastian (unregistered) in reply to channer
    channer:
    sure - to members, but methods?

    Why not? I use it so that I can quickly tell the difference between public and private methods. I picked it up in Objective-C where there are no private methods and it's used as a way of flagging "hey, don't touch!" for other programmers. It turns out that I find it makes the code a little bit more readable in other languages, too, so I started using it all the time.

    Sure it's arbitrary and not really necessary, but then so is every other naming and formatting convention.

  • Just Me (unregistered) in reply to Taevin
    Taevin:
    Rick:
    Anonymous:
    It's standard practice to represent floats/decimals in integer form. Otherwise you get funky rounding things happening when you multiply or divide. It's just a fact of life. It gets worse in finance, as some things go to 32'nds and beyond and you are using a large value to begin with.

    Soo... typically you'd do everything in integer/long form and display it in float/decimal form to minimize the damage by using String manipulation.

    No, finance people do not like it when numbers get botched out of their control. :)




    I think finance people get more upset when their values get truncated due to the maximum size of an integer. After factoring the loss of 2 decimal places isn't the allowable range -21,474,836.48 to +21,474,836.47???

    I know those numbers are too small for the financial company that I work for.


    Maybe they should use unsigned long long(s)?

    unsigned long long (64 bits) 0 to 18,446,744,073,709,551,615

    If anyone or any company has that much money.... address and bank vault pass code please? :)



    Umm... what about everyone added together at micro$oft? ;)

  • (cs) in reply to smbell
    smbell:
    Pingmaster:

    Soooo...instead of storing all numbers as decimals and just tuncating 0 to n characters after the decimal based on how the user wanted to display the number, they decide to complicate this by making everything integers, not to mention that one can no longer have large decimal places (i.e. .4294967297 can not exist) and they've only added to the complexity by stating that you have to take an ordinary integer value and add a decimal to it, instead of saying it's a number, just tell us how many places after the decimal you want to see...

    I just wonder what the function would look like to add 0.0234 + 1.0417.....or even worse, division...


    Once again the comments approach the level of WTF as the code example.  Storing numbers and decimal when dealing with money is unacceptable due to the imprecise nature of decimal numbers.  They are merely an approximation, not an exact value.

    This obscures the fact that most modern languages (.NET included) have support for accurate decimal number representation in the form of some math library or class (I think in .NET it is BigDecimal?).  That is 'the real WTF'.

    K, so you tell me exactly where in my post I mentioned dealing with currency...besides, wasn't I talking about using the decimal data type instead of integer in the first place?  it'd be nice if people actually read the posts before replying.

    Oh, BTW, if you wanted to do currency arithmetic as cents, could you not multiply the existing value by 100, then 'convert' it to integer by removing everything after the decimal then performing the mathematical operation?  Although I'd keep it as decimal myself because most financial calculations these days use money values with 4 decimal places so that there's minimal loss due to rounding, therefor making interger calculations as cents useless (since it would then truncate any 0.5 cent values, causing monetary 'loss' or 'gain' in the system due to truncation errors). And as far as BigDecimal, i think you're thinking about one of the new SQL data types in 2005...cuz it doesn't exist in .NET 2, and I don't remember seeing it in 1.1 either.

  • Yaytay (unregistered) in reply to Bastian

    Anonymous:
    channer:
    sure - to members, but methods?
    Why not? I use it so that I can quickly tell the difference between public and private methods. I picked it up in Objective-C where there are no private methods and it's used as a way of flagging "hey, don't touch!" for other programmers. It turns out that I find it makes the code a little bit more readable in other languages, too, so I started using it all the time. Sure it's arbitrary and not really necessary, but then so is every other naming and formatting convention.

    It's not arbitrary in C++.

    Having an underscore at the start of a name has a very specific meaning and should not be done in your own code.

    Not sure if it's the same for C, probably isn't like that for C#.

  • foxyshadis (unregistered) in reply to APAQ11
    Anonymous:

    I am a fan of the CEF because I have always hated decimal numbers.

     

    DOWN WITH PI!!!!

     

    haha captcha = STFU


    How does one represent 1/12 or 1/365 in fixed point again? =p

    Anonymous:
    viraptor:
    merreborn:
    Jesus Christ:
    <font color="#ff0000" face="Verdana" size="6">>:3</font>



    God damnit, we've been 4chan'd.  Get in the car.

    THIS is a real WTF (... sandwich. It's made of 4chan, lion, wft code and getting into.)



    I'm sorry, I don't speak jibberish

    'NUFF JIBBA JABBA, POOL'S CLOSED

    <font size="1">I am a slave to the meme.</font>
  • foxyshadis (unregistered) in reply to Yaytay
    Anonymous:

    Anonymous:
    channer:
    sure - to members, but methods?
    Why not? I use it so that I can quickly tell the difference between public and private methods. I picked it up in Objective-C where there are no private methods and it's used as a way of flagging "hey, don't touch!" for other programmers. It turns out that I find it makes the code a little bit more readable in other languages, too, so I started using it all the time. Sure it's arbitrary and not really necessary, but then so is every other naming and formatting convention.

    It's not arbitrary in C++.

    Having an underscore at the start of a name has a very specific meaning and should not be done in your own code.

    Not sure if it's the same for C, probably isn't like that for C#.


    Technically, it's only reserved in the global namespace, and class members should be fine (aside from VC6's horrible scoping); it's only when a uppercase letter follows the underscore when you risk hitting random macros. Just ensure that no intellisense window pops up when you type out your member name for the first time.

    It's not like you're going to run up against severe problems that crash weirdly on random compilers unless you're "enthusiastically" cross-platform, like say, mozilla.
  • Shepherd (unregistered)

    ok i give up, what happens if i do this

    x = 100/30;  ?

  • (cs) in reply to Alex Papadimoulis
    Alex Papadimoulis:

    Come one guys, if you're thinking "OMFGWTFBBQ!! He used a | instead of a ||" when you see the article, you need to go back and read it again. You missed the part where the CEF system uses only numbers and strings and requires a database call to convert integers to decimals.



    Wait a minute, that is a database call?  So, for each time I want to print out information, I must pay a penalty of an I/O call?  Then, with this database possibly being used by a lot of simultaneously running programs, I can see this system screaming to a crawl, given enough of a load, of course.

  • FirstLol!! (unregistered) in reply to ChiefCrazyTalk

    At all those who think integer for financial math is a good thing. No it is not.
    In the finance sectore they use the BDC format for calculations. And believe it or not, but your x86 FPU actually supports  BCD calculation.

  • gRegor (unregistered) in reply to Anon
    Anonymous:
    I wonder what their system does for dates?


    eHarmony.com ?

    The e is for enterprise, of course.
  • (cs) in reply to Ford351-4V

    Ford351-4V:
    Makes me wonder what the ReturnBooleanResult() method looks like.

    No! Wait! I was only kidding.

    ...Seeing as you asked...

    public string ReturnBooleanResult(int number, string field, string entity)
    {
      //throw exception if bad input
      if (field.Length == 0 || entity.Length == 0) return "false";
    

    if (number != 0) return "TRUE"; else if (number == 0) return "No"; return "FileNotFound"; }

  • Boy with balls on chin (unregistered)

    <FONT size=5><: ( 3</FONT>

  • Terance (unregistered)

    There is another WTF here.
    They used a StringBuilder object.
    The StringBuilder is great for large data, or data that is going to be appended to a lot. But it is going to impace performance when you start to have more than a few dozen.

    This is in a class used for every integer/decimal data type. There is going to be quite a few here.

    Their attempt increase speed is going to have the opposite effect.  

  • just a regular visitor (unregistered)

    Alex Papadimoulis:

    public string SetDecimalPlace(int number, string field, string entity)
    {
      //throw exception if bad input
      if (field.Length == 0 || entity.Length == 0) return "-1";

    <!-- snip -->


    }

    Well because noone else pointed out, the code doesn't check field == null before using the Length property, so if someone would be so foolish, that they would pass a null reference to the method, the method itself would cause NullReferenceException, but naturally in this system it would be the callers fault..

  • John the man savage (unregistered)

    Ok seeing shit like this is really starting to piss me OFF! You total idiots!!!! STOP WRITING SHIT. I'M FUCKING SERIOUS you bag lickers.

     

    Captcha = tps

  • Pyrolistical (unregistered)

    Wow.

    Here's a site to catch other people's wtfs and right in the text they promote a wtf in itself.

    You should never represent money with floating point!  You will be out of a job real fast once your accounting department can't figure out why doesn't everything total at the end of the day.

    Another value that should never be represented as a decimal is a unit of time.  Always use an integer for time, or else you will run into floating point issues just as you did if you used it to represent money.

  • (cs)
     //throw exception if bad input
    if (field.Length == 0 || entity.Length == 0) return "-1";

    Shock and Awe isn't it? This line of code sets them back to the medieval era.

    return "-1" HAHAHAHAHHAaaaaaahahhhhhrgggggggggggg......

  • (cs) in reply to exussum
    Anonymous:
    It's standard practice to represent floats/decimals in integer form. Otherwise you get funky rounding things happening when you multiply or divide. It's just a fact of life. It gets worse in finance, as some things go to 32'nds and beyond and you are using a large value to begin with. Soo... typically you'd do everything in integer/long form and display it in float/decimal form to minimize the damage by using String manipulation. No, finance people do not like it when numbers get botched out of their control. :)


    Let my give that a try
    1 ct + 4 cts divided by two... Hey I still got a rounding problem, maybe the rounding problem is because the destination precison is 2 decimals and it's not an input problem...
  • RichNFamous (unregistered)

    Hm - that's called 'crossing the river to get some water'. Someone please invent a device that can stab lousy coders in the face, remotely...

  • Rudi (unregistered) in reply to Private. Hudson
    Anonymous:
    Well that's great, that's just fuckin' great man. Now what the fuck are we supposed to do? We're in some real pretty shit now man... That's it man, game over man, game over! What the fuck are we gonna do now? What are we gonna do?


    Nice quote from Aliens, weird nobody else commented before?

Leave a comment on “Enterprise Beautification”

Log In or post as a guest

Replying to comment #:

« Return to Article