- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
oh wow ..
programmer not using standardlib episode number 5326
Admin
They should have serialized to XML somewhere in there. Then the circle of insanity would be complete.
Admin
Ohh my god.... Why you punish me with this abomination??
Admin
Just to make sure we're on the same page, that function is 700% longer than it needs to be.
Return EvaluationDate.AddMonths(-1)
Admin
Admin
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.
Admin
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.
Admin
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!
Admin
Strings should be way more difficult to use and not as ubiquitous as they are.
.toString() is like a drug:
Admin
Admin
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!
Admin
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
Admin
is 700% longer but the consultant used StringBuilder instead of String so he is a SENIOR consultant
Admin
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.
Admin
... and get on with life.
Admin
pretty smart....
Admin
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().
Admin
Just out of curiousity, in what language is this written?
Admin
Admin
Admin
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?"
Admin
return (new DateTime( EvaluationDate.Year, EvaluationDate.Month, 1 ) ).AddDays( -1 );
Admin
Regarding the 10 chars, you must be confusing Perl with APL.
Admin
Every time see a post about something written in VB or whatever.NET I think that the language is the WTF.
Admin
No, those could do with 5!
Admin
Wow, that's an amazing quote. Five Stars!!
Admin
This is not as bad as the original code so I think that makes him a junior consultant.
Admin
Unfortunately I know that it is VB.Net
Admin
It looks like the typical code put out by some of the vb "experts" I manage now.
Admin
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.
Admin
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.
Admin
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.
Admin
/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?
Admin
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.
Admin
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.
Admin
I'm hoping he just missed his sarcasm tags. If not well....... I weep for the future of our society.
Admin
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.
Admin
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...
Admin
Maybe they wanted the last day of the previous month. I've seen SQL functions that do the same thing.
Admin
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.
Admin
[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.
Admin
Admin
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
Admin
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.
Admin
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.
Admin
myDate.AddDays(myDate.Day * -1)
/Consultant /Certified /HaveTheTShirt
Admin
and the WTF comment is...
Admin
"Have you tried Javascript?"
Admin
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.
Admin