| « Prev | Page 1 | Page 2 | Page 3 | Next » |
Re: Enterprise Incrementation
2011-01-24 09:03
•
by
Non-consultant
(unregistered)
|
|
This kind of thing is all too common from consultants... :S
|
|
That always happens with code written by $200/hr consultants..
Captcha - populus http://en.wikipedia.org/wiki/Populus |
Re: Enterprise Incrementation
2011-01-24 09:04
•
by
Enterprise Guy
(unregistered)
|
|
And I can bet they call these function via SOAP to make it more enterprisey
|
|
I wonder if Jose C's middle intial is B.
|
|
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. |
|
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] |
|
|
So, if its "Enterprise Incrementation", can we shorten that to "excrementation"?
|
|
I'm pretty sure I would have put whatever consultant wrote this through a "JavaScript compiler" and converted him into "byte-code."
|
Re: Enterprise Incrementation
2011-01-24 09:33
•
by
Marcio
(unregistered)
|
AssignCommentInToOut('Fail') |
That's more like it. Choosing proper function names is an essential part of writing well documented code. |
Re: Enterprise Incrementation
2011-01-24 09:45
•
by
4Reel
(unregistered)
|
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. |
|
Could we fall back on Newspeak and describe this as double-plus-ungood?
|
Re: Enterprise Incrementation
2011-01-24 09:46
•
by
Perl Guru
(unregistered)
|
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." |
|
If that code is what I think it is, and I think it is JavaScript, then they whould have had the source anyway.
|
|
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?
|
Re: Enterprise Incrementation
2011-01-24 09:54
•
by
octal
(unregistered)
|
|
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... |
Re: Enterprise Incrementation
2011-01-24 09:55
•
by
Pyroka
(unregistered)
|
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 |
|
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 +=
|
Re: Enterprise Incrementation
2011-01-24 09:58
•
by
JamesQMurphy
|
|
Re: Enterprise Incrementation
2011-01-24 10:00
•
by
pfoof
(unregistered)
|
Can you not increment by two? |
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 :-) |
|
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.
|
Re: Enterprise Incrementation
2011-01-24 10:09
•
by
George Fitch
(unregistered)
|
|
No, it isn't. Read method #2 closer.
|
Re: Enterprise Incrementation
2011-01-24 10:11
•
by
George Fitch
(unregistered)
|
|
Let me try this again...
No, it isn't. Read method #2 closer. |
|
Who hasn't written something like this?
I are a consultant and should be banned from my mommy and daddy's modem. - frits |
return IncrementByOne(IncrementByOne('ungood'));
|
Re: Enterprise Incrementation
2011-01-24 10:21
•
by
Sudo
(unregistered)
|
Perhaps that's where so many coders are going wrong... if they stopped using dollars and switched to euros, maybe their code quality would improve?... I charge in GB pounds. The quality of my code is undefined. |
Re: Enterprise Incrementation
2011-01-24 10:27
•
by
I-am-Stupid
(unregistered)
|
|
... but it's the operator overloading (of +) that causes this problem, not the dynamic typing.
Using + for string concatenation is the dumb. |
Re: Enterprise Incrementation
2011-01-24 10:43
•
by
berglebuddy
(unregistered)
|
|
Using . string concatenation is the dumb.
|
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. |
|
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. |
Re: Enterprise Incrementation
2011-01-24 11:00
•
by
Chris
(unregistered)
|
And (according to a quick Google) Javascript doesn't implicitly cast int to string, so calling parseInt(anInt) would cause an error. |
Re: Enterprise Incrementation
2011-01-24 11:02
•
by
queso
(unregistered)
|
|
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) |
|
IncrementByOne is probably not a WTF. It is probably a call back for some RPC/XHR request.
|
|
IncrementByOne. One function point, 1 hour: $200.
AssignStringInToOut. Zero function points: Priceless. |
|
function IncrementByOne(input) {
var output = parseInt(input); return output + 1; } and then call IncrementByOne('08') and watch the sparks ... |
Re: Enterprise Incrementation
2011-01-24 11:48
•
by
Mike
(unregistered)
|
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. |
|
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? |
|
Everyone knows "IncrementByOne" is actually spelled std::bind2nd(std::plus<int>,1) which is much clearer.
|
Re: Enterprise Incrementation
2011-01-24 11:57
•
by
Ken B.
(unregistered)
|
Actually, his middle name is "Cañu". |
Re: Enterprise Incrementation
2011-01-24 12:05
•
by
Mike
(unregistered)
|
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" |
|
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.
|
|
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. |
|
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. |
Re: Enterprise Incrementation
2011-01-24 12:16
•
by
vfdsabfvht
(unregistered)
|
|
What is the reason to name such void function? It can be perfectly anonymous, there is no advantage of "DoNothing" over "function(){}".
|
Re: Enterprise Incrementation
2011-01-24 12:16
•
by
anon
(unregistered)
|
Good point. Here, let me fix it: function IncrementByOne(input) { var output = parseInt(input + ''); return output + 1; } Perfect! |
Win! |
|
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. |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |