• Non-consultant (unregistered)

    This kind of thing is all too common from consultants... :S

  • buji (unregistered)
    Comment held for moderation.
  • Enterprise Guy (unregistered)

    And I can bet they call these function via SOAP to make it more enterprisey

  • frits (cs)

    I wonder if Jose C's middle intial is B.

  • Someone You Know (cs)

    Say what you want about the first one, but at least it does something.

    The use of the var keyword in the second one makes it a no-op.

  • frits (cs) in reply to Someone You Know
    Someone You Know:
    Say what you want about the first one, but at least it does something.

    The use of the var keyword in the second one makes it a no-op.

    Returning the parameter untouched makes it worse than a noop due to function call overhead.

  • toth (cs)

    The increment one isn't (necessarily) a WTF. As far as I can recall, in Javascript, a string plus a number concatenates the number to the string. Since the function calls parseInt(), it's fair to assume that input is a string. Sure, you could say parseInt() + 1 every time, but isn't that function much simpler?

    [/troll]

  • George Fitch (unregistered)
    function AssignCommentInToOut(input) {
        var output = "Frist";
        return input;
    }
    
  • Two (unregistered)

    So, if its "Enterprise Incrementation", can we shorten that to "excrementation"?

  • boog (unregistered)

    I'm pretty sure I would have put whatever consultant wrote this through a "JavaScript compiler" and converted him into "byte-code."

  • Marcio (unregistered) in reply to George Fitch
    George Fitch:
    function AssignCommentInToOut(input) {
        var output = "Frist";
        return input;
    }
    

    AssignCommentInToOut('Fail')

  • Arvind (unregistered)
    function AssignStringInToOutThenReturnIn(input) {
        var output = input;
        return input;
    }
    

    That's more like it. Choosing proper function names is an essential part of writing well documented code.

  • 4Reel (unregistered) in reply to toth
    toth:
    The increment one isn't (necessarily) a WTF. As far as I can recall, in Javascript, a string plus a number concatenates the number to the string. Since the function calls parseInt(), it's fair to assume that input is a string. Sure, you could say parseInt() + 1 every time, but isn't that function much simpler?

    [/troll]

    This explains very succinctly why dynamic typing bothers me. I'm sure there's a more graceful way to deal with it, and it's not like THIS is required, but still - having to fight with the interpreter so that it treats a value as the data-type I want defeats the point of an ultra-high level language.

  • encre (unregistered)

    Could we fall back on Newspeak and describe this as double-plus-ungood?

  • Perl Guru (unregistered) in reply to Arvind
    Arvind:
    function AssignStringInToOutThenReturnIn(input) {
        var output = input;
        return input;
    }
    

    That's more like it. Choosing proper function names is an essential part of writing well documented code.

    I'm sorry. No. Uh uh. The words "documented" and "code" are incompatable. You dum programmers write something called "code" and expect it to be understandable? There is not now, or will there ever be such a thing as "documented code."

  • Scott (unregistered)

    If that code is what I think it is, and I think it is JavaScript, then they whould have had the source anyway.

  • anon (unregistered)

    I might have been spending too long in C++land, but that second one is hilarious. Doesn't that just leak memory? At least temporarily, until the garbage collector gets around to picking it up?

  • octal (unregistered) in reply to anon

    What happens if the string begins with "0" - don't you need parseInt(input, 10) ???

    And doesn't "increment" mean "add one" anyway. IncrementByOne is tautological...

  • Pyroka (unregistered) in reply to Perl Guru
    Perl Guru:
    Arvind:
    function AssignStringInToOutThenReturnIn(input) {
        var output = input;
        return input;
    }
    

    That's more like it. Choosing proper function names is an essential part of writing well documented code.

    I'm sorry. No. Uh uh. The words "documented" and "code" are incompatable. You dum programmers write something called "code" and expect it to be understandable? There is not now, or will there ever be such a thing as "documented code."

    Note that when we say documented code, we mean documented so other programmers can understand it, I don't really care if someone who can't spell 'dumb' can't understand my code.

    Go back to spending your life writing pointless word documents and leave the people with brain cells to do the coding.

    sigh feeding troll I know

  • rfoxmich (unregistered)

    Those functions were clearly intended to be embedded in the database as stored procedures. After all, you would want to insulate your application code from the fact that the business logic might want to morph 1 -> 2 and assignment to +=

  • JamesQMurphy (cs) in reply to encre
    encre:
    Could we fall back on Newspeak and describe this as double-plus-ungood?
    function MakeDoublePlusUn(input)
    {
       var output = input.ToString();
       return "doubleplusun" + output;
    } 
    
  • pfoof (unregistered) in reply to octal
    octal:
    What happens if the string begins with "0" - don't you need parseInt(input, 10) ???

    And doesn't "increment" mean "add one" anyway. IncrementByOne is tautological...

    Can you not increment by two?

  • bjolling (cs) in reply to buji
    Non-consultant:
    This kind of thing is all too common from consultants... :S
    buji:
    That always happens with code written by $200/hr consultants..

    Captcha - populus

    http://en.wikipedia.org/wiki/Populus

    I'm €125/hr consultant and the only comments I receive from a client's code review is that my code is perfect. Of course, they also have to review what their offshore teams are checking in :-)

  • Chris (unregistered)

    I always hate WTF's based on "omg that's a simple function". without context I have no idea if these were meant to be the equivalent of function-pointers/functors. In such a case, you might have a "foreach x in y: if is_predicate() then a() else b();" template set up somewhere, where "is_predicate(), a(), b()" are arguments. perhaps is_predicate(), a(), or b() will end up being a simple "do nothing", increment, or comparison. In that case, "DoNothing" makes a lot of sense. The code has to call a function, nothing needs to be done, so the "DoNothing" function is used.

  • George Fitch (unregistered) in reply to Marcio

    No, it isn't. Read method #2 closer.

  • George Fitch (unregistered) in reply to Marcio

    Let me try this again...

    Marcio:
    George Fitch:
    function AssignCommentInToOut(input) {
        var output = "Frist";
        return input;
    }
    

    AssignCommentInToOut('Fail')

    No, it isn't. Read method #2 closer.

  • frits (unregistered)

    Who hasn't written something like this?

    I are a consultant and should be banned from my mommy and daddy's modem.

    • frits
  • lolwtf (cs) in reply to encre
    encre:
    Could we fall back on Newspeak and describe this as double-plus-ungood?
    return IncrementByOne(IncrementByOne('ungood'));
  • Sudo (unregistered) in reply to bjolling
    Comment held for moderation.
  • I-am-Stupid (unregistered) in reply to 4Reel

    ... but it's the operator overloading (of +) that causes this problem, not the dynamic typing.

    Using + for string concatenation is the dumb.

  • berglebuddy (unregistered) in reply to I-am-Stupid

    Using . string concatenation is the dumb.

  • Zylon (cs) in reply to 4Reel
    4Reel:
    This explains very succinctly why dynamic typing bothers me. I'm sure there's a more graceful way to deal with it, and it's not like THIS is required, but still - having to fight with the interpreter so that it treats a value as the data-type I want defeats the point of an ultra-high level language.
    Are you dumb, or trolling? The only time you should have to "fight" to maintain the correct data type is when accepting unsanitized input or doing type coercision... which is the exact same thing you have to do with strictly-typed languages.
  • TheChewanater (cs)

    These (or at least the first one) may be meant for callbacks. Whoever wrote this was probably using lambdas so often they decided to put it into its own function.

    something.connectSignal ("click", incrementByOne, foo);

    Of course, the fact that they return a value might make this example not work... It depends on how their callback are called.

  • Chris (unregistered) in reply to 4Reel
    4Reel:
    toth:
    The increment one isn't (necessarily) a WTF. As far as I can recall, in Javascript, a string plus a number concatenates the number to the string. Since the function calls parseInt(), it's fair to assume that input is a string. Sure, you could say parseInt() + 1 every time, but isn't that function much simpler?

    [/troll]

    This explains very succinctly why dynamic typing bothers me. I'm sure there's a more graceful way to deal with it, and it's not like THIS is required, but still - having to fight with the interpreter so that it treats a value as the data-type I want defeats the point of an ultra-high level language.

    And (according to a quick Google) Javascript doesn't implicitly cast int to string, so calling parseInt(anInt) would cause an error.
  • queso (unregistered) in reply to toth

    or you could just call ++ on it?

    I know I shouldn't feed, but:

    even if the number (for some reason) had a '0' at the beginning, it would push it to base 8

    There's no reason to FIGHT the typing of the language, work with a language, not against it.

    (ECMAScript developer here, and it's a pretty nice language if you know it)

  • benh999 (unregistered)

    IncrementByOne is probably not a WTF. It is probably a call back for some RPC/XHR request.

  • Coyne (cs)

    IncrementByOne. One function point, 1 hour: $200.

    AssignStringInToOut. Zero function points: Priceless.

  • Hans (unregistered)

    function IncrementByOne(input) { var output = parseInt(input); return output + 1; }

    and then call

    IncrementByOne('08')

    and watch the sparks ...

  • Mike (unregistered) in reply to I-am-Stupid
    I-am-Stupid:
    ... but it's the operator overloading (of +) that causes this problem, not the dynamic typing.

    Using + for string concatenation is the dumb.

    What does it matter if you are using the text "a.concat(b)" or "a + b"? The result is the same. The automatic cast is the problem.

  • Anonymous (unregistered)

    More shitty consultant code, what a big surprise. You know how we have that rule that no student code is allowed? It's a fair rule, students don't know a lot about the real world and we know their code is going to be rubbish so there's not much point in laughing at the useless little buggers.

    Shouldn't we have the same rule for consultants?

  • GWO (unregistered)

    Everyone knows "IncrementByOne" is actually spelled std::bind2nd(std::plus<int>,1) which is much clearer.

  • Ken B. (unregistered) in reply to frits
    frits:
    I wonder if Jose C's middle intial is B.
    Actually, his middle name is "Cañu".
  • Mike (unregistered) in reply to Zylon
    Zylon:
    4Reel:
    This explains very succinctly why dynamic typing bothers me. I'm sure there's a more graceful way to deal with it, and it's not like THIS is required, but still - having to fight with the interpreter so that it treats a value as the data-type I want defeats the point of an ultra-high level language.
    Are you dumb, or trolling? The only time you should have to "fight" to maintain the correct data type is when accepting unsanitized input or doing type coercision... which is the exact same thing you have to do with strictly-typed languages.

    The real issue is auto-casting, not dynamic typing. Both Javascript, which is dynamically typed, and Java, which is strongly typed, will screw you here. Java at least tells you what kind of things you're passing around though. This mostly helps the guy who shows up after you to have half a chance of understanding what you were trying to do.

    Javascript: document.write( '1' + 1 ); Output is "11"

    Java: System.out.println( "1" + 1 ): Output is "11"

  • XXXXX (unregistered)

    Given any function for doing something, there must necessarily exist a less-efficient way of doing the same thing.

    Thus I submit the following as a 1000 fold improvement to their design.

    function AssignStringInToOut(input) {
        for (var i = 0; i < 1000; i++) {
          var output = input;
        }
        return input;
    }
    
  • Bryan the K (unregistered)

    For $200 an hour I'd expect some WSDL files or at least some XML Serialization....you know, because that's how they do things.

    CAPTCHA: consequat : The consequat of my actions were thus noted.

  • iToad (unregistered)

    I see the problem. Each of these functions is missing the standard comment that we have to place at the beginning of each and every function, regardless of length. This header includes:

    • Repeat of function header.
    • Description of all arguments, both type and purpose.
    • Purpose of the function.
    • List of other functions called by this function.
    • Inputs.
    • Outputs.
    • Global variables modified.
    • Interfaces and resources used (Files, GUIs, etc...)
    • Limitations.
    • Assumptions.
    • Change history.
    • Notes.

    They removed the part where you were supposed to list all the other functions that called this function.

  • vfdsabfvht (unregistered) in reply to Chris

    What is the reason to name such void function? It can be perfectly anonymous, there is no advantage of "DoNothing" over "function(){}".

  • anon (unregistered) in reply to Chris
    Chris:
    4Reel:
    toth:
    The increment one isn't (necessarily) a WTF. As far as I can recall, in Javascript, a string plus a number concatenates the number to the string. Since the function calls parseInt(), it's fair to assume that input is a string. Sure, you could say parseInt() + 1 every time, but isn't that function much simpler?

    [/troll]

    This explains very succinctly why dynamic typing bothers me. I'm sure there's a more graceful way to deal with it, and it's not like THIS is required, but still - having to fight with the interpreter so that it treats a value as the data-type I want defeats the point of an ultra-high level language.

    And (according to a quick Google) Javascript doesn't implicitly cast int to string, so calling parseInt(anInt) would cause an error.

    Good point. Here, let me fix it:

    function IncrementByOne(input) { var output = parseInt(input + ''); return output + 1; }

    Perfect!

  • frits (cs) in reply to Ken B.
    Ken B.:
    frits:
    I wonder if Jose C's middle intial is B.
    Actually, his middle name is "Cañu".

    Win!

  • Lucas (unregistered)

    About this $200/hr, do they actually charge $200/hr for everyone in the team who wrote funny lines of code, or you just see the invoice and assume that there aren't like 5 other $20/hr programmers from another continent behind this $200/hr consultant?

    Please, my question is serious. I can kind of program and I would like to go up from $20 to $200.

Leave a comment on “Enterprise Incrementation”

Log In or post as a guest

Replying to comment #:

« Return to Article