• yername (unregistered)
    Jon adds, "it wouldn't be so bad, except this same code is repeated 10 lines further down to pad something else to 8 chars. And the business wonders why it takes so long to create new reports..."

    If 38 comparisons take too long, the real problem is that the hardware you're using is too slow.

  • Luiz Felipe (unregistered) in reply to Sigivald
    Sigivald:
    Time Bandit said: .NET programmers think that their language is the best because they don't know any better.

    Yeah, plainly.

    (Is it also true that non-.NET programmers don't realize that .NET isn't a language?

    And that they don't get that "real programmers use .NET" was a joke in response to "real programmers would use recursion"?)

    No, you are wrong. Real programmers use .NET framework and creates his own languague on top of it. I dont use any of Csharp or Vbasic fledged languages, i make my own.

    Plus for job security. I love money also.

  • Anonymous Cow-orker (unregistered)

    The real WTF is a language without (s/f)printf.

  • morkk (unregistered) in reply to some dude
    some dude:
    Bananas:
    I prefer Vim myself. Type the first line, then qwyyp3w^k4w^k5w^k5w^kq

    Then @w as many times as you need. Or in this case, just 28@w

    BTW, I've mapped the Ctrl-K key to the increment function.

    This is why vim makes me hot.

    He hasn't shown you the size of his ^K yet!

  • (cs) in reply to feugiat
    feugiat:
    Herby:
    In my first (no frist) programming class I was taught the concept of a loop. That was back in the 60's. I don't think the basic concepts have changed much, but the quality of the instruction seems to have changed quite a bit, as witnessed by code examples like this.

    The sad part is that this "programmer" was probably a graduate of a "top tier" school (or his resume said so). Sad, very sad!

    Does that mean you're 65-70 years old?

    Fortunately it's not illegal yet to be elderly, although in some places in the world it gets you seriously discriminated against by certain societal factions. Now GET OFF MY LAWN!

  • JustSomeGuy (unregistered) in reply to Brian White
    Brian White:
    Do you need a loop for string padding? I typically set a variable to a very long series of empty spaces, like 100 or so, then just do: Right(padVar & realVar, 30)

    Which works right up until the point you want a 101-character string :-)

  • Arrows (unregistered) in reply to Bananas
    Bananas:
    BTW, I've mapped the Ctrl-K key to the increment function.
    What's wrong with the standard Ctrl-A?
  • (cs) in reply to Luiz Felipe
    Luiz Felipe:
    Sigivald:
    Time Bandit said: .NET programmers think that their language is the best because they don't know any better.

    Yeah, plainly.

    (Is it also true that non-.NET programmers don't realize that .NET isn't a language?

    And that they don't get that "real programmers use .NET" was a joke in response to "real programmers would use recursion"?)

    No, you are wrong. Real programmers use .NET framework and creates his own languague on top of it. I dont use any of Csharp or Vbasic fledged languages, i make my own.

    Plus for job security. I love money also.

    Real programmers code in custom macro languages in LISP or (shiver) C++.

  • (cs) in reply to MarkJ
    MarkJ:
    SQLDave:
    Coyne:
    This is quite a pattern: We could use it all sorts of ways:

    //Add 5 to number a[0] = in; a[1] = 1; a[2] = 1; a[3] = 1; a[4] = 1; a[5] = 1; int out = 0; out = a[0]; out = out + a[1]; out = out + a[2]; out = out + a[3]; out = out + a[4]; out = out + a[5]; }

    Think of the efficiency improvements!

    FTFY. (I removed that horrible loop)

    Remember, loops are like the definition of insanity: repeating the same thing over and over, expecting different results!
    You know you've reached a new level of Zen in programming, when you realize that there are no loops. There are only sets undergoing a sequence of operations.

    Loops that don't act like that are considered ugly.

    Do not try to comprehend the loop; that is impossible. Only try to realize the truth: there is no loop.

  • Marty (unregistered) in reply to Nelson

    Modula-2?

    Akismet really sucks at figuring out spam. Cripes.

  • (cs) in reply to Bananas
    Bananas:
    BTW, I've mapped the Ctrl-K key to the increment function.

    I find it works a lot better to map screen's escape to Ctrl-Z. That's used a lot less often than Ctrl-A, so it's not that inconvenient, and that way I don't need to remap Ctrl-A in:

    • My shell
    • My editor
    • My text-mode web browser
    • My pager
    • My etc.

    Or do you have a different reason to dislike the vim default for increment?

  • Luiz Felipe (unregistered) in reply to hoodaticus
    hoodaticus:
    Luiz Felipe:
    Sigivald:
    Time Bandit said: .NET programmers think that their language is the best because they don't know any better.

    Yeah, plainly.

    (Is it also true that non-.NET programmers don't realize that .NET isn't a language?

    And that they don't get that "real programmers use .NET" was a joke in response to "real programmers would use recursion"?)

    No, you are wrong. Real programmers use .NET framework and creates his own languague on top of it. I dont use any of Csharp or Vbasic fledged languages, i make my own.

    Plus for job security. I love money also.

    Real programmers code in custom macro languages in LISP or (shiver) C++.

    Are you saying to use C++ template metaprogramming to write a new language. Cool ideia, i will try it now.

  • Anne Thwacks (unregistered) in reply to Yazeran

    Why did the developer not stop after the first 5 lines or so and thought 'I wonder if there is a better way of doing this?'.

    Becasue he was paid by SLOC?

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

  • Darn Kid (unregistered) in reply to Herby

    You might try asking these "programmers" to get off your lawn.

  • Mouser (unregistered) in reply to Nobody You Know
    Nobody You Know:
    Gary:
    Alternatively:
    while str.length <> 30 {str = str + ' '};
    

    "Hey, why does this pad function lock up and allocate a bunch of memory when I give it a 40-character string?"

    Obviously didn't read the post above about cutting and pasting from file. This wouldn't work in a 'cut-n-past' coding environment. :)
  • Premature Optimizer (unregistered)

    I can duplicate that functionality in 2 lines of code!

  • Mike (unregistered) in reply to frist

    Congrats on being "frist".

Leave a comment on “The String Padding Trick”

Log In or post as a guest

Replying to comment #:

« Return to Article