How many spaces?



  • I found this gem in our application today (a 'mission critial' financial app):

     public static final String twentyspaces = "                        ";

     Fantastic!



  • or how about

    public String space(int sp){ String temp =""; for(int x=0;x<sp;x++){temp= temp+" ";} return temp;} 



  • lol!

    Is there also

    public static final String thirteenampersands = "&&&&&&&&&&&&&";

    or maybe

    public static final String sevendollarsignsfollowedbyasingleasterisk = "$$$$$$$*";



  • well, we could go with the following:

     

    public static final String alternatingpercentkeyandexclamationpointkeywithatrailingcaratkey = "%!%!%!%!%!....^" 



  • There is a deeper WTF going on here that nobody has mentioned yet (hint: paste that line into an editor with a fixed width font and start counting...!)



  • [quote user="jminkler"]

    or how about

    public String space(int sp){ String temp =""; for(int x=0;x<sp;x++){temp= temp+" ";} return temp;} 

    [/quote]

    Well, VB has a built-in function for that, hasn't it?

    Public Shared Function Space(ByVal Number As Integer) As String

    Namespace: Microsoft.VisualBasic

    Module: Strings

    Assembly: Microsoft Visual Basic .NET Runtime (in Microsoft.VisualBasic.dll)

     

     



  • Oh that's even better.

    I guess the correct name for the const should have been something like SPACER_STRING. It probably started out being 20 spaces.

     



  • [quote user="qbolec"][quote user="jminkler"]

    or how about

    public String space(int sp){ String temp =""; for(int x=0;x<sp;x++){temp= temp+" ";} return temp;} 

    [/quote]

    Well, VB has a built-in function for that, hasn't it?

    Public Shared Function Space(ByVal Number As Integer) As String

    Namespace: Microsoft.VisualBasic

    Module: Strings

    Assembly: Microsoft Visual Basic .NET Runtime (in Microsoft.VisualBasic.dll)

     It sure does ...

     

    [/quote]


  • This reminds me of CSS like this:

    .blue-arial {
      color: gray;
      font-family: serif;
    }
    

    The real WTF is the naming convention. What kind of freak uses all lowercase and no underscores?



  • public static final String twodoubleyousthreeteestwoessesonenoneytwoeffsoneoonuonertwospacesoneponectwoeesandtwoquestionmarksarrangededinameaningfullpattern =

    "WTF? Twentyfour spaces?"

    ;

     



  • Twenty spaces North, and twenty-four spaces West. W, T and F mark the spot. Yarr!

    </stupid pirate joke>



  • [quote user="jminkler"]

    or how about

    public String space(int sp){ String temp =""; for(int x=0;x<sp;x++){temp= temp+" ";} return temp;} 

    [/quote]

    maybe 

     

    public String createSpacer(char ch, int length) {

      char[] arr = new char[length];

      java.util.Arrays.fill(arr, ch);

      return new String(arr);



  • [quote user="visitor2"][quote user="jminkler"]

    or how about

    public String space(int sp){ String temp =""; for(int x=0;x<sp;x++){temp= temp+" ";} return temp;} 

    [/quote]

    maybe 

     

    public String createSpacer(char ch, int length) {

      char[] arr = new char[length];

      java.util.Arrays.fill(arr, ch);

      return new String(arr);

    [/quote]

    or how about ....

     calling VB's space(20) through java !

    Brillant !! 



  • [quote user="HeroreV"]

    This reminds me of CSS like this:

    .blue-arial {
    color: gray;
    font-family: serif;
    }

    The real WTF is the naming convention. What kind of freak uses all lowercase and no underscores?

    [/quote]

    Err... you're joking right? Replying to the wrong post? I don't get it...

     



  • [quote user="HeroreV"]

    This reminds me of CSS like this:

    .blue-arial {
    color: gray;
    font-family: serif;
    }

    The real WTF is the naming convention. What kind of freak uses all lowercase and no underscores?

    [/quote]

    What the fuck??? Your post is just as amusing as the original.



  • [quote user="qbolec"][quote user="jminkler"]

    or how about

    public String space(int sp){ String temp =""; for(int x=0;x<sp;x++){temp= temp+" ";} return temp;} 

    [/quote]

    Well, VB has a built-in function for that, hasn't it?

    Public Shared Function Space(ByVal Number As Integer) As String

    Namespace: Microsoft.VisualBasic

    Module: Strings

    Assembly: Microsoft Visual Basic .NET Runtime (in Microsoft.VisualBasic.dll)

    [/quote]

    Do you honestly think that calling Space(20) is smarter than creating a variable called "twentySpaces"? 

    Which one of these do you think costs more?

    1)  Write 20 bytes to memory once.  Read those 20 bytes from memory, say 10,000 times.

    2)  Write 20 bytes to memory, read those 20 bytes, free that memory.  Repeat 10,000 times.




  • If you didn't understand my post it's probably just because you don't know CSS. Consider this example:

    <!-- HTML -->
    <p class="blue-arial">some text some text some text</p>
    /* CSS */
    .blue-arial {
      color: blue;
      font-family: Arial;
    }
    

    The text in the paragraph would be blue and in the Arial font. Later on the HTML may stay the same while the CSS is changed, which is why class names shouldn't imply any kind of styling.

    Get it now? 24 spaces named "twentyspaces" and a class named "blue-arial" that doesn't make the text blue or Arial?



  • [quote user="HeroreV"]

    If you didn't understand my post it's probably just because you don't know CSS. Consider this example:

    <!-- HTML -->
    <p class="blue-arial">some text some text some text</p>
    /* CSS */
    .blue-arial {
    color: blue;
    font-family: Arial;
    }

    The text in the paragraph would be blue and in the Arial font. Later on the HTML may stay the same while the CSS is changed, which is why class names shouldn't imply any kind of styling.

    Get it now? 24 spaces named "twentyspaces" and a class named "blue-arial" that doesn't make the text blue or Arial?

    [/quote]

    The real WTF(TM) is that you needed to explain that... 



  • [quote user="HeroreV"]

    This reminds me of CSS like this:

    .blue-arial {
    color: gray;
    font-family: serif;
    }

    The real WTF is the naming convention. What kind of freak uses all lowercase and no underscores?

    [/quote]

    Your analogy is valid, but the answer to your question is:  "Good CSS writers."

    Hyphens are an established convention in CSS.  All the (multi-word) CSS keywords use them.

    Underscores reduce readability, especially when used in multiple consecutive lines.  Granted, they're better than no word separator at all, but the only reason they were used in programming languages like C is that no other word separators were allowed.

    Hyphens are also ever so slightly faster to type, seeing as most (all?) keyboards do not require pressing Shift to type them.



  • [quote user="VGR"]

    Hyphens are also ever so slightly faster to type, seeing as most (all?) keyboards do not require pressing Shift to type them.

    [/quote]

    No they're not. Pressing shift runs in parallel to pressing the _/- key. It takes just as long to reach the _/- key when your other hand is headed to the shift key as when your other hand is remaining still.

    sincerely,
    Richard Nixon
     



  • I think he was referring to the OP with the naming convention thing.

    In java, constants should LOOK_LIKE_THIS (as is the generally accepted convention).



  • [Code][quote user="Moto42"]

    public static final String two-double-u's-three-t's-two-s's-one-no-nay-two-f's-one-o-one-u-one-r-two-spaces-one-p-one-c-two-e's-and-two-questionmarks-arranged-in-a-meaningful-pattern =

    "WTF? Twentyfour spaces?"

    ;

     

    [/quote][/Code]

    For my next act I'll now nicely seperate this string into a readable name while laughing out loud. 



  • [quote user="Richard Nixon"][quote user="VGR"]

    Hyphens are also ever so slightly faster to type, seeing as most (all?) keyboards do not require pressing Shift to type them.

    [/quote]

    No they're not. Pressing shift runs in parallel to pressing the _/- key. It takes just as long to reach the _/- key when your other hand is headed to the shift key as when your other hand is remaining still.

    sincerely,
    Richard Nixon
     

    [/quote]

    Aaaah, but I beg to differ. I type with one finger, and it takes me infintely longer to type an underscore. this is why I name my variables blue-underscore-arial.



  • I use ascii codes to write code.

    My numpad gets quite the workout.
     



  • [quote user="Some Idiot"][quote user="Richard Nixon"][quote user="VGR"]

    Hyphens are also ever so slightly faster to type, seeing as most (all?) keyboards do not require pressing Shift to type them.

    [/quote]

    No they're not. Pressing shift runs in parallel to pressing the _/- key. It takes just as long to reach the _/- key when your other hand is headed to the shift key as when your other hand is remaining still.

    sincerely,
    Richard Nixon
     

    [/quote]

    Aaaah, but I beg to differ. I type with one finger, and it takes me infintely longer to type an underscore. this is why I name my variables blue-underscore-arial.

    [/quote]
    <font face="tahoma,arial,helvetica,sans-serif">thanks1 i really need a good laugh today... ;0



    </font>



  • [quote user="Thanny"]

    Do you honestly think that calling Space(20) is smarter than creating a variable called "twentySpaces"? 

    [/quote]

    No. I just found it funny, that the VB runtime library has a function for such a thing. Probably the reason for that was, using it formatting printouts, which is the really WTF idea (because it leads straight to mixing logic with presentation layer). I forgot to put a sarcasm tag for you, though. It would be probably slower but more accurate to change 20 to 24 in all of the places where Space() is called, than redefine "twentySpaces" to be equal 24 spaces.

    But why am I forced to use it more than once?

    [code]const string theGap= spaces(24); // I don't know what language is that:)[/code]

    ...and I don't know why the " ' " gets urlencoded twice when used inside code tag....



  • [quote user="Thanny"][quote user="qbolec"][quote user="jminkler"]

    or how about

    public String space(int sp){ String temp =""; for(int x=0;x<sp;x++){temp= temp+" ";} return temp;} 

    [/quote]

    Well, VB has a built-in function for that, hasn't it?

    Public Shared Function Space(ByVal Number As Integer) As String

    Namespace: Microsoft.VisualBasic

    Module: Strings

    Assembly: Microsoft Visual Basic .NET Runtime (in Microsoft.VisualBasic.dll)

    [/quote]

    Do you honestly think that calling Space(20) is smarter than creating a variable called "twentySpaces"? 

    Which one of these do you think costs more?

    1)  Write 20 bytes to memory once.  Read those 20 bytes from memory, say 10,000 times.

    2)  Write 20 bytes to memory, read those 20 bytes, free that memory.  Repeat 10,000 times.


    [/quote]

    Absoulutely not, that's why I said "or how about this" refering to wtf code I have seen before, and have wrote in my early days to format things, luckily I know better now.

     



  • Check out the front page... ;)



  • Hurray!  It made the front page!


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.