• Quicksilver (unregistered)

    oh wow ..

    programmer not using standardlib episode number 5326

  • Dak (unregistered)

    They should have serialized to XML somewhere in there. Then the circle of insanity would be complete.

  • Rafael Larios (unregistered)

    Ohh my god.... Why you punish me with this abomination??

  • Dave Smith (unregistered)

    Just to make sure we're on the same page, that function is 700% longer than it needs to be.

    Return EvaluationDate.AddMonths(-1)

  • snoofle (unregistered) in reply to Dave Smith
    Dave Smith:
    Just to make sure we're on the same page, that function is 700% longer than it needs to be.

    Return EvaluationDate.AddMonths(-1)

    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.

  • (cs) in reply to Dave Smith

    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.

  • T$ (unregistered)

    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.

  • Matt (unregistered)

    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!

  • (cs)

    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
  • Someone (unregistered) in reply to skington
    skington:
    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 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)
  • mav (unregistered) in reply to Matt

    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!

  • barf indeedy (unregistered)

    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

  • marcello (unregistered) in reply to Dave Smith

    is 700% longer but the consultant used StringBuilder instead of String so he is a SENIOR consultant

  • (cs) in reply to snoofle
    snoofle:
    Dave Smith:
    Just to make sure we're on the same page, that function is 700% longer than it needs to be.

    Return EvaluationDate.AddMonths(-1)

    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.
    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.

  • (cs)
    Return New DateTime(evaluationDate.Year, evaluationDate.Month, 1).Subtract(TimeSpan.FromDays(1))

    ... and get on with life.

  • Alex S. (unregistered)

    pretty smart....

  • (cs)

    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().

  • Steve (unregistered)

    Just out of curiousity, in what language is this written?

  • EmmanuelD (unregistered) in reply to whoahman
    whoahman:
    Return New DateTime(evaluationDate.Year, evaluationDate.Month, 1).Subtract(TimeSpan.FromDays(1))
    ... and get on with life.
    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.
  • EmmanuelD (unregistered) in reply to Steve
    Steve:
    Just out of curiousity, in what language is this written?
    Very Basic. I think.
  • anne (unregistered) in reply to H|B
    H|B:
    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

    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?"

  • RON (unregistered) in reply to snoofle
    snoofle:
    Dave Smith:
    Just to make sure we're on the same page, that function is 700% longer than it needs to be.

    Return EvaluationDate.AddMonths(-1)

    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.

    return (new DateTime( EvaluationDate.Year, EvaluationDate.Month, 1 ) ).AddDays( -1 );

  • Kai (unregistered) in reply to H|B
    H|B:
    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().

    Regarding the 10 chars, you must be confusing Perl with APL.

  • (cs) in reply to EmmanuelD
    EmmanuelD:
    Steve:
    Just out of curiousity, in what language is this written?
    Very Basic. I think.

    Every time see a post about something written in VB or whatever.NET I think that the language is the WTF.

  • (cs) in reply to Kai
    Kai:
    H|B:
    Speaking of small programs, where are the Perl coders? I'm sure some of them could program 10-char PriorMonths().

    Regarding the 10 chars, you must be confusing Perl with APL.

    No, those could do with 5!

  • RonaldRoss (unregistered) in reply to H|B
    H|B:
    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

    Wow, that's an amazing quote. Five Stars!!

  • PS (unregistered) in reply to EmmanuelD
    EmmanuelD:
    whoahman:
    Return New DateTime(evaluationDate.Year, evaluationDate.Month, 1).Subtract(TimeSpan.FromDays(1))
    ... and get on with life.
    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.

    This is not as bad as the original code so I think that makes him a junior consultant.

  • PS (unregistered) in reply to Steve
    Steve:
    Just out of curiousity, in what language is this written?

    Unfortunately I know that it is VB.Net

  • packrat (unregistered)

    It looks like the typical code put out by some of the vb "experts" I manage now.

  • (cs)

    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.

  • (cs) in reply to packrat
    packrat:
    It looks like the typical code put out by some of the vb "experts" I manage now.

    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.

  • rgz (unregistered) in reply to mav
    mav:
    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!

    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.

  • (cs) in reply to rgz
    rgz:
    mav:
    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!

    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?

  • rgz (unregistered) in reply to kimos
    kimos:
    EmmanuelD:
    Steve:
    Just out of curiousity, in what language is this written?
    Very Basic. I think.

    Every time see a post about something written in VB or whatever.NET I think that the language is the WTF.

    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.

  • jread (unregistered)

    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.

  • SomeCoder (unregistered) in reply to JamesKilton
    JamesKilton:
    rgz:
    mav:
    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!

    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?

    I'm hoping he just missed his sarcasm tags. If not well....... I weep for the future of our society.

  • rgz (unregistered) in reply to JamesKilton
    JamesKilton:
    /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?

    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.

  • Zygo (unregistered) in reply to JamesKilton
    JamesKilton:
    rgz:
    mav:
    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!

    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?

    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...

  • ForcedSterilizationsForAll (unregistered) in reply to skington

    Maybe they wanted the last day of the previous month. I've seen SQL functions that do the same thing.

  • Eduardo Habkost (unregistered)

    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.

  • Freddy Bob (unregistered) in reply to Gsquared

    [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.

  • Freddy Bob (unregistered) in reply to Gsquared
    Gsquared:
    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.
    Languages, no. Libraries, maybe.
  • Joon (unregistered)

    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

  • (cs) in reply to JamesKilton
    JamesKilton:
    rgz:
    mav:
    And the raven, never flitting, still is sitting, still is sitting On the pallid bust of Derrick Pallas just above my chamber door; ...
    That's pretty neat! Did you made it?
    /sigh. What is happening to this country? People aren't taught who Poe is? Or at least this, his most famous poem?

    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.

  • rgz (unregistered) in reply to jread

    I apologize for the incoming spelling mistakes, because apologizing is easier than reaching a dictionary.

    jread:
    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.

    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.

  • (cs) in reply to Quicksilver

    myDate.AddDays(myDate.Day * -1)

    /Consultant /Certified /HaveTheTShirt

  • Boink (unregistered) in reply to jread

    and the WTF comment is...

    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.

  • JUST ANOTHER WTF (unregistered) in reply to Dak
    Dak:
    They should have serialized to XML somewhere in there. Then the circle of insanity would be complete.

    "Have you tried Javascript?"

  • Izzy (unregistered) in reply to Dave Smith

    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.

  • (cs) in reply to H|B
    H|B:
    Speaking of small programs, where are the Perl coders? I'm sure some of them could program 10-char PriorMonths().
    Maybe not 10 characters...
    use Date::Calc qw(:all);
    sub subtract_month ($$$) {
      my ($year, $month, $day) = Add_Delta_YMD(@_, 0, -1, 0);
      $day = Days_in_Month($year, $month);
      return ($year, $month, $day);
    }
    

Leave a comment on “Time for Consultants”

Log In or post as a guest

Replying to comment #:

« Return to Article