|
|
|
| Non-WTF Job: C++ Developer at Good Grievance (Ronkonkoma, NY) |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
oh wow ..
programmer not using standardlib episode number 5326 |
|
They should have serialized to XML somewhere in there. Then the circle of insanity would be complete.
|
|
Ohh my god.... Why you punish me with this abomination?? |
|
Just to make sure we're on the same page, that function is 700% longer than it needs to be.
Return EvaluationDate.AddMonths(-1) |
Re: Time for Consultants
2007-04-24 09:18
•
by
snoofle
(unregistered)
|
Not so sure - the way they did it, I think it winds up as the last date of the prior month. Of course, you did it the way it's named. |
|
It also turns e.g. all dates between 2007-04-01 and 2007-04-30 into 2007-03-31 - possibly not what the caller of the function was expecting.
|
|
I may be pointing out the obvious, but I find it hilarious that they've written a function to subtract time and it's supposed to be saving the company time (in development) but is really adding time for the processing to complete. How ironic.
|
|
It was specifically coded this way to avoid handling the inevitable ThirtyDaysHathSeptemberException...
Captcha: muhahaha. I dont know why people find this entertaining, but here is the word i had to type. Enjoy! |
|
Strings should be way more difficult to use and not as ubiquitous as they are.
.toString() is like a drug: - you think you know how to use it harmlessly - it leaves the impression that it makes everything easier - soon you will be using it uncontrollably everywhere - people who don't "do it" feel sorry for you and think you have deep problems |
Re: Time for Consultants
2007-04-24 09:27
•
by
Someone
(unregistered)
|
I guess they wanted this alright, since they did also find and use the AddDay() method. But the string conversion is just wrong, not only is it inefficient, it can also easily break (no culture was specified, which then defaults to the current user's culture being used for formats). They maybe wanted something like input.Date.AddDays(-input.Day) |
Re: Time for Consultants
2007-04-24 09:28
•
by
mav
(unregistered)
|
|
And the raven, never flitting, still is sitting, still is sitting
On the pallid bust of Derrick Pallas just above my chamber door; And his eyes have all the seeming of a demon's that is dreaming, And the lamp-light o'er him streaming throws his shadow on the floor; And my soul from out that shadow that lies floating on the floor Shall be lifted - nevermore! |
|
hey, check it out... Maybe for some odd reason they were calling this function over and over and over, and realized the power of stringbuilder over string concatenation in the .net world... They just saved themselves a whole lot of needless GC!!
:P I know I know, not getting at the WTF in the post. And yeah, it's a pretty blatant WTF. Hey guys, let's make a useless method more efficient!!! :D |
Re: Time for Consultants
2007-04-24 09:49
•
by
marcello
(unregistered)
|
|
is 700% longer but the consultant used StringBuilder instead of String so he is a SENIOR consultant
|
Not sure how to do this in whatever language the original is in, but in T-SQL, if the desired result is the last day of the prior month (as opposed to actually a month earlier, as the name implies): create function PriorMonth (@Date datetime) returns datetime as begin return (select dateadd(day, -1 * datepart(day, @date), @date)) end That avoids all the string conversions, etc. (For anyone who doesn't know, "@" is how you prefix variables in T-SQL. Having it in parens after the function name declares it as an input parameter.) I'm reasonably sure most languages have some similar functionality to T-SQL's "dateadd" and "datepart". Might even have the same name. I've just never used any of them. |
Return New DateTime(evaluationDate.Year, evaluationDate.Month, 1).Subtract(TimeSpan.FromDays(1)) ... and get on with life. |
|
pretty smart....
|
|
AFAIK, after Kurt Gödel (or Alan Turing?), there is no way of knowing the smallest possible program for any given task...
Speaking of small programs, where are the Perl coders? I'm sure some of them could program 10-char PriorMonths(). |
|
Just out of curiousity, in what language is this written?
|
Re: Time for Consultants
2007-04-24 09:59
•
by
EmmanuelD
(unregistered)
|
You're clearly a senior consultant too. But remember that being too good means that you'll never be featured here, and that's a terrible lack of publicity. |
Re: Time for Consultants
2007-04-24 10:00
•
by
EmmanuelD
(unregistered)
|
Very Basic. I think. |
Re: Time for Consultants
2007-04-24 10:00
•
by
anne
(unregistered)
|
this reminds me of something someone said at my last job: "Goto is like marijuana. It should be legal, as long as people use it responsibly." Our manager replied, "So do you eat a bag of Doritos after you use a lot of gotos?" |
Re: Time for Consultants
2007-04-24 10:02
•
by
RON
(unregistered)
|
return (new DateTime( EvaluationDate.Year, EvaluationDate.Month, 1 ) ).AddDays( -1 ); |
Re: Time for Consultants
2007-04-24 10:15
•
by
Kai
(unregistered)
|
Regarding the 10 chars, you must be confusing Perl with APL. |
Every time see a post about something written in VB or whatever.NET I think that the language is the WTF. |
No, those could do with 5! |
Re: Time for Consultants
2007-04-24 10:22
•
by
RonaldRoss
(unregistered)
|
Wow, that's an amazing quote. Five Stars!! |
Re: Time for Consultants
2007-04-24 10:28
•
by
PS
(unregistered)
|
This is not as bad as the original code so I think that makes him a junior consultant. |
Re: Time for Consultants
2007-04-24 10:30
•
by
PS
(unregistered)
|
Unfortunately I know that it is VB.Net |
|
It looks like the typical code put out by some of the vb "experts" I manage now.
|
|
It appears to be for some sort of billing system or something similar where it doesn't matter what day it is. You only care about a month and a year when you're doing a report or something of that nature. I don't know why all the conversions, but it's not a complete disaster. It's more like a car crash than the Hindenburg.
|
Hehe, there are some great VB programmers out there. Sounds like a bunch of losers swindled HR and you got stuck with the garbage. Look for another job or take part in the hiring process. |
Re: Time for Consultants
2007-04-24 10:45
•
by
rgz
(unregistered)
|
That's pretty neat! Did you made it? I do support captcha reporting, but captchas are only funny when they funny (du'h) and when they are related to the subject or comentary. This one was neither. |
/sigh. What is happening to this country (yes, I'm assuming the person above is American)? People aren't taught who Poe is? Or at least this, his most famous poem? |
Re: Time for Consultants
2007-04-24 10:52
•
by
rgz
(unregistered)
|
Excuse me but there is nothing basic about Visual Basic .NET, the shit is syntax hell. Intentional torture languages (INTERCAL, Brainfuck, Shakespeare etc) not withstantanding. |
|
Wow, I'm glad to finally see some VB.NET code on here.
Also, why does everyone think that VB is a "lesser" language? That gets really annoying. VB.NET and C# are (functionally) the same damn language. |
Re: Time for Consultants
2007-04-24 10:57
•
by
SomeCoder
(unregistered)
|
I'm hoping he just missed his sarcasm tags. If not well....... I weep for the future of our society. |
Re: Time for Consultants
2007-04-24 10:58
•
by
rgz
(unregistered)
|
Fortunately, I'm not American, nor a native speaker, and have never lived in an English speaking country. And I know who wrote the raven, even if I didn't study it in high school. That should make you, us, feel better. Oh and the RWTF is the forum software. |
Re: Time for Consultants
2007-04-24 11:07
•
by
Zygo
(unregistered)
|
I'll admit that I only know this because it was used in a Simpsons episode. But at least I do know it, and who originally wrote it... |
Re: Time for Consultants
2007-04-24 11:08
•
by
ForcedSterilizationsForAll
(unregistered)
|
|
Maybe they wanted the last day of the previous month. I've seen SQL functions that do the same thing.
|
|
People really love strings. When they don't know how to do some operation with the data, they just convert it to a string and perform the operation on the string representation.
|
Re: Time for Consultants
2007-04-24 11:16
•
by
Freddy Bob
(unregistered)
|
|
[quote user="Gsquared"][quote user="snoofle"]
I'm reasonably sure most languages have some similar functionality to T-SQL's "dateadd" and "datepart". Might even have the same name. I've just never used any of them.[/quote] Languages, no. Libraries, maybe. |
Re: Time for Consultants
2007-04-24 11:16
•
by
Freddy Bob
(unregistered)
|
Languages, no. Libraries, maybe. |
|
This is hilarious!
They must have run FxCop on the code, it complained about the string concatenation (using + on strings in .NET has a huge overhead), and then they "Fixed" the code so that FxCop does not complain: Brilliant |
If it makes you feel better, I had "the pallid bust of Pallas" as the caption for a photo on my home page a couple of years ago. |
Re: Time for Consultants
2007-04-24 11:35
•
by
rgz
(unregistered)
|
|
I apologize for the incoming spelling mistakes, because apologizing is easier than reaching a dictionary.
Yes but in VB you have Subrutines, Functions, and Functions that not return a value, and you can asign the return value to the function name, or not. It has class less methods which is not a wtf, but an inconsistency with c#. And is awfully verbose, you have to write 'Dim mfoo as Foo' when 'Foo mfoo' could sufise and 'new Foo()' instead of 'Foo()' and of course that means that you would have to write 'Dim mFoo as Foo = new Foo()'! then to cover up for this insanity shortcuts are invented and you end up with more syntax like 'Dim mfoo as new Foo()' which is still too long, 'mfoo as Foo()' could be a perfect declare+initialize idiom. It's deciving, 'Dim foo, bar, baz as String' declares to generic object variables and a String variable. The ternary operator works different across versions, operating buzyly or lazyly with unspected results. And when it works lazily it makes even less sense since it uses the syntax of function calling. Array indexing is indistiguible from function calling. Casting is cumbersome. Initializing Arrays is cumbersome No multiline string means you have to concatenate long messages, inserting new line objects in between since it doesn't understand about \\n. The ide fills in this for you but you have to put 'ByVal' and 'ByRef' for each parameter in the function declaration, and yes it is the function and not the caller who decides if it works on objects or only their values. No intelligent line wraping means you can't breakup a complicated instruction into several lines with a continuation character that must be placed correctly for it to work right. I haven't learn how to do templating, but i bet it will be full of wtf. I have the language and I hate that I have to code it for a living. Still looking for a Pythonist job. Might as well start a Python shop myself. |
|
myDate.AddDays(myDate.Day * -1)
/Consultant /Certified /HaveTheTShirt |
Re: Time for Consultants
2007-04-24 11:45
•
by
Boink
(unregistered)
|
|
and the WTF comment is...
|
Re: Time for Consultants
2007-04-24 11:45
•
by
JUST ANOTHER WTF
(unregistered)
|
"Have you tried Javascript?" |
Re: Time for Consultants
2007-04-24 11:46
•
by
Izzy
(unregistered)
|
|
You forget, this is generated by consultants. Their design criteria include bloat, obfustification, and excessive use of resources. You wouldn't pay them lots of money if it was 12 pages and ran on a 386.
|
Maybe not 10 characters...
|
| « Prev | Page 1 | Page 2 | Page 3 | Next » |