• (cs)

    The fact that he even gets paid to write code like this is a big WTF.

  • eddie (unregistered) in reply to 1900 is not evil!
    Anonymous:
    Hugo:

    ammoQ:

    IMO, this code is not a big WTF.

    Eh? How can a function that claims to check if a date is valid, yet accepts dates such as "27/14/2005", "25/ab/cdef", or "29/02/1900" NOT be a WTF?

    "27/14/2005", "25/ab/cdef" are definately invalid, but i wouldn't call "29/02/1900" invalid. :) Allthough it might be some time ago, 29th of Feburary 1900 is a pretty valid date. :)

    (unless you're from usa ofcause. Their date-format has been scrambled in some arbitrary order).

    <FONT color=#ff0000>Something didn't quite work out ...
    - CAPTCHA Validation Incorrect </FONT>

    1900 is not an leapyear...

    [pi]

  • Ferdy (unregistered) in reply to Maz

    As indicated earlier, this language is Lotusscript, not VB. Stop halts the debugger, Lotusscript also has a slightly different syntax than VB. Suggesting to upgrade to .Net is a plain silly remark, as Lotus Notes and .Net are in different markets.

  • ServerDude (unregistered) in reply to josh
    Anonymous:
    Anonymous:
    Unfortunately this doesn't take account of the fact that years divisible exactly by 100 aren't leap years unless they are also divisible exactly by 400.


    Even more unfortunately, it doesn't matter.  Assuming that uninitialized variables are set to 0 in this language, every year is a leap year.


    Yeah.. really a nice touch, every year will be assumed to be year 0, which is an invalid date.

    Furthermore, dates such as 29/02-0000 or indeed 29/02.abcd are allowed, which seems strange to me- not that it hasn't been pointed out before, I just wanted to complain about the delimiters

  • (cs) in reply to ammoQ
    ammoQ:

    250 USD/h is a WTF on its own, unless the other code written by that guy contains special knowledge that makes it worth the money or the guy produces at least 2500 reasonably well written lines of code per day.


    80 cents per well-written line of code is ridiculously low. Not even guys from India or eastern Europe work that cheap unless you count every change made during debugging as a new line of code.. In fact I'm pretty sure nobody can write 2500 lines of good code per day except when using code generators or maybe when starting a new project from scratch rather than working in a huge system they don't understand completely, which is the norm.

  • (cs) in reply to Paul O
    Anonymous:

    In the early- to mid-80's, the standard was anywhere from $8 to $20 for each line of debugged code.

    Of course, that was before languages like C made you write ten lines to accomplish the simplest of tasks,


    Uh... so what were those languages in wide use before C that were more expressive and efficient? Fortran? COBOL??
  • (cs) in reply to brazzy
    brazzy:
    Anonymous:

    In the early- to mid-80's, the standard was anywhere from $8 to $20 for each line of debugged code.

    Of course, that was before languages like C made you write ten lines to accomplish the simplest of tasks,


    Uh... so what were those languages in wide use before C that were more expressive and efficient? Fortran? COBOL??

    Lisp or Smalltalk i guess, even though "wide use" would be highly debatable.

  • (cs) in reply to Not Telling
    Anonymous:


    here here!!
    Oh wait, I work for IBM.
    Ignorance is bliss, ask any of my blissful colleagues.



    Hey Mr Blissful, that would be "hear hear"

    how amusing

  • (cs)
           i = i + 2
       Next

    <FONT color=#000000>When the <FONT color=#0000ff>Next</FONT> statement is encountered, the iteration variable (i) is incremented and then checked against its upper limit, in the absense of a Step clause with a negative value.  That is why the "+2" actually results in a +3 increment.</FONT>

      For
    ...
    If
    Not ( <FONT color=#000000>separator</FONT> = "/" Or <FONT color=#000000>separator</FONT> = "-" Or <FONT color=#000000>separator</FONT> = "." ) Then
    ...
    Next

    <FONT color=#000000>I would think a better string pattern match would be the following.  No looping.</FONT>

    <FONT color=#0000ff>If</FONT> dateString <FONT color=#0000ff>Like</FONT> "##[/,-,.]##[/,-,.]####" <FONT color=#0000ff>Then</FONT>

    While the <FONT face="Courier New">IsDate()</FONT> function will validate both mmddyyyy and ddmmyyyy date format orders, it fails to correctly validate either ordering when a period, ".", separator is used.  However, two substitutions or a date conversion will generate correct results.

    Period Substitution: 
    Mid(datestring,3,1) = "/"
    Mid(datestring,6,1) = "/"
    If IsDate(datestring) Then ...
    Conversion (into a Date/Time variable) ignores periods:
    DateSerial(Mid(datestring,7,4), Mid(datestring,4,2), Mid(datestring,1,2))

    I'm surprised no one has mentioned the absense of the Trim() function to remove leading/trailing spaces.

    I will give at least one kudo to the coder that commented the dates were coming in as dd/mm/yyyy and that empty strings were acceptable values into this function.

    What I found curiously interesting was the number of line-combining characters (:) used at the end of the <FONT face="Courier New">Case</FONT> clauses.

    What does this coder care if the leap year check isn't valid?!?  They've got their share of the money and they count on being dead by the time the logic error bites the client in 2100.

  • SirLaughsAlot (unregistered)

    <SARCASM warning="goggles" mode="on">

    This code sucks, squeezes, bangs and blows.  Holy twister of unholy logic batman, he just created a jet engine!

    </SARCASM>

  • (cs) in reply to brazzy
    brazzy:
    ammoQ:

    250 USD/h is a WTF on its own, unless the other code written by that guy contains special knowledge that makes it worth the money or the guy produces at least 2500 reasonably well written lines of code per day.

    80 cents per well-written line of code is ridiculously low. Not even guys from India or eastern Europe work that cheap unless you count every change made during debugging as a new line of code.. In fact I'm pretty sure nobody can write 2500 lines of good code per day except when using code generators or maybe when starting a new project from scratch rather than working in a huge system they don't understand completely, which is the norm.



    Of course 2500 lines of code per day is unrealistic, but so is 250 USD/h ;-). Depending on the language and tools it's not totally unreasonable to expect 500 lines per day and pay 50 USD/h; or even expect 250 lines of code per day and pay 25 USD/h  (normal rates in Eastern Europe).





  • (cs) in reply to brazzy
    brazzy:

    Uh... so what were those languages in wide use before C that were more expressive and efficient? Fortran? COBOL??


    PL/1 comes to my mind.
  • AndrewN (unregistered) in reply to bramster

    No where did he specify that it cost $2000, only that they were paying $2000/day.
    Using your 11 lines per day 83/11 * 2000 = $15,090.90 for this function.

    Being a WTF it's not debugged so expect a small discount from this number.

    PS. If you want to hire me instead I'll guarantee my code is better than this for the
    same price :-)

  • (cs) in reply to AndrewN
    Anonymous:

    PS. If you want to hire me instead I'll guarantee my code is better than this for the
    same price :-)


    Sorry, this market is price-driven, quality doesn't matter. Therefore: I can offer the same quality of code for 80% of the price. ;-)
  • (cs) in reply to 1900 is not evil!
  • Paul O (unregistered) in reply to ammoQ
    ammoQ:
    brazzy:

    Uh... so what were those languages in wide use before C that were more expressive and efficient? Fortran? COBOL??


    PL/1 comes to my mind.

    Perhaps people are confusing the C language with the Standard C Library, which, while standardized alongside the language, is not part of the language itself.

    e.g. http://www.acm.uiuc.edu/webmonkeys/book/c_guide/

    Just because you didn't program it doesn't mean it wasn't programmed.

    And no, this is not a statement that one approach is better than another:  clearly, there is value in writing support routines in the language itself to allow easier portability of the underlying language.  The comment was about the number of lines of code needed to achieve certain things.


  • Ben (unregistered) in reply to ammoQ

    ammoQ:
    Anonymous:

    PS. If you want to hire me instead I'll guarantee my code is better than this for the
    same price :-)


    Sorry, this market is price-driven, quality doesn't matter. Therefore: I can offer the same quality of code for 80% of the price. ;-)

    That's genius! I laughed out loud at this one! [:D]

    I can offer you 45% of the price, for code that is 120% as shit!

    P.S. This happens everytime you first submit a post as an anonymous user:
    <FONT color=#ff0000>Something didn't quite work out ...
    - CAPTCHA Validation Incorrect</FONT>

    Sort it out Alex!

  • (cs)

    I especially like the manually incremented FOR loop.

  • Dave (unregistered) in reply to bit
    bit:
    I especially like the manually incremented FOR loop.

    I'm not sure I see the problem with the manual increment (beyond the poor documentation):  the code intends to only check positions 3 and 6 (2 and 5?? Where's my reference guide? anyway, the separator positions) within the string.  Sure, the author could have simply extracted mid(,3,) and (,6,) and duplicated the if statement, but either approach can be successful.

    What I worry about is seeing an assignment, rather than a comparison, in the if statement ...
       if Not ( seperator = "/" Or separator = "-" Or separator = "."  ) ...
  • Anonymity (unregistered) in reply to Ben
    Anonymous:

    P.S. This happens everytime you first submit a post as an anonymous user:
    <font color="#ff0000">Something didn't quite work out ...
    - CAPTCHA Validation Incorrect</font>

    Sort it out Alex!


    It's because the CAPTCHA image is fetched once when the page is loaded.  Then you spend a few minutes writing your message, and by the time you hit Send then the CAPTCHA image has rolled on.  (I'm not certain, but I suspect that it changes every minute.)

    Ideally the page should have a little JavaScript snippet to refresh the image whenever it changes.  Until then, you'll just have to live with it.  Or register :)
  • (cs)

    Seriously...  This guy obviously was writing this code in a data-type sparse environment.


    Looking through the code, he's replaced the functionality of Boolean, Long/Float/Double, and Date types by just using Integer and String.


    This bastard ought to be commended for his creative ignorance of the simple solution.


    Wouldn't you love to see the IsTrue() and IsFalse() functions written by this dude?

  • fsd vdaf sfaf234 (unregistered) in reply to llxx

    ON ERROR fuck it

  • (cs) in reply to Ferdy
    Anonymous:
    As indicated earlier, this language is Lotusscript, not VB. Stop halts the debugger, Lotusscript also has a slightly different syntax than VB. Suggesting to upgrade to .Net is a plain silly remark, as Lotus Notes and .Net are in different markets.


    Stop is also in VB

    http://courses.nnu.edu/cs226bm/appendixA.htm
  • (cs) in reply to Dave

    Anonymous:
    bit:
    I especially like the manually incremented FOR loop.

    I'm not sure I see the problem with the manual increment (beyond the poor documentation):  the code intends to only check positions 3 and 6 (2 and 5?? Where's my reference guide? anyway, the separator positions) within the string.  Sure, the author could have simply extracted mid(,3,) and (,6,) and duplicated the if statement, but either approach can be successful.

    What I worry about is seeing an assignment, rather than a comparison, in the if statement ...
       if Not ( seperator = "/" Or separator = "-" Or separator = "."  ) ...

     

    In basic '=' is both an assignment AND a comparison. The compiler figures out which you want. For example, this is valid (albeit a bit unreadable):

    a = (b = c)

    a will be 'true' if b equals c, and 'false' otherwise.

    Drak

  • The-Nit (unregistered) in reply to Anonymous

    Anonymous:
    The real WTF here is that the month and day are switched.

    Ok, you have never been to europe, where we write, dd/mm/yyyy.

    So no, its not really a wtf, if he was expecting the user to write the date in this format.

    Thanks.

  • (cs)

    My guess is that this "coder" is perfectly aware of the IsDate() function, but he couldn't justify charging $2000 for a single line of code, now could he?

    So, bad coder? or good (yet shady) businessman?

  • (cs) in reply to b1xml2

    b1xml2:
    Anonymous:
    As indicated earlier, this language is Lotusscript, not VB. Stop halts the debugger, Lotusscript also has a slightly different syntax than VB. Suggesting to upgrade to .Net is a plain silly remark, as Lotus Notes and .Net are in different markets.


    Stop is also in VB

    http://courses.nnu.edu/cs226bm/appendixA.htm

    I'll have to confirm that. Just tested it in VB6 and it just breaks to the debugger.

  • ed (unregistered) in reply to ammoQ

    Wow, where 25 USD/h is normal in Eastern Europe? Just curious, I'm in Eastern Europe (on the southern part), I get about 6 USD/h, and this is quite high here (and quite ridiculous by you standarts :-/)

  • (cs) in reply to ed

    Anonymous:
    Wow, where 25 USD/h is normal in Eastern Europe? Just curious, I'm in Eastern Europe (on the southern part), I get about 6 USD/h, and this is quite high here (and quite ridiculous by you standarts :-/)

    Lets just say I won't get out of bed for any less than €25 p/h [:P]

  • (cs) in reply to ed
    Anonymous:
    Wow, where 25 USD/h is normal in Eastern Europe? Just curious, I'm in Eastern Europe (on the southern part), I get about 6 USD/h, and this is quite high here (and quite ridiculous by you standarts :-/)


    Slowakia, when you work for e.g. Austrian companies. (I live in Austria, less than 100 km from the Slovakian border).
    But don't get me wrong: I don't say that the programmers get 25 USD/h (or rather 20-25 EUR/h), it's just that the companies charge that much for their work.
  • Maty (unregistered) in reply to boohiss

    No, it's because stupid programmer.

    Maybe he did'nt know about IsDate function but,

    Code is too large,some parts are useless

    My favorite section

           'extract the parts of the date string
           theDay = Mid ( dateString, 1, 2  )
           theMonth = Mid ( dateString, 4, 2)
           theYear = Mid ( dateString, 7, 4 )
          
           This is really stupid, string theDay,theMonth,theYear will never be ""
           If theYear = "" Then
                validDate = False
                Exit Function
           End If
          
           If theDay = "" Then
                validDate = False
                Exit Function
           Else
                dayNumber = Cint ( theDay )
           End If
          
           If theMonth = "" Then
                validDate = False
                Exit Function
           Else
                monthNumber = Cint ( theMonth )
           End If
    Function work only with specific format of date,what about anothert separator,datetime...

     

    If you thik this is good code,please don't speak about programming

    and try paper and pen.....

  • (cs)

    $250/h!!!
    And this is a prove of why outsourcing works!

    I work for $6.25/h and my code is much better than this crap. for the price of 1 day of this guy you get 2 month of mine  wow! :'(

  • (cs) in reply to Rank Amateur
    Rank Amateur:

    Yeah, "-6/31/WTF?" should be considered a completely valid date. Make sure the user is using separators I find acceptable --that's the most important thing. And for God's sake, don't accept something like "11/2/2005" or "Nov 2 2005" or any of that nonsense. I'm a $2500/day consultant and you shall conform to my format for dates. Resistance is futile.

    --Rank

    how about:

    "-6-31.WTF?" [:)]

  • (cs) in reply to SirLaughsAlot

    Anonymous:
    This code sucks, squeezes, bangs and blows.  Holy twister of unholy logic batman, he just created a jet engine!

    Well, while I'm not familiar for the workings of a jet engine, what you are descriping is a 4-stroke, internal combustion (ie, automobile) engine.

  • (cs) in reply to JamesCurran
    JamesCurran:

    Anonymous:
    This code sucks, squeezes, bangs and blows.  Holy twister of unholy logic batman, he just created a jet engine!

    Well, while I'm not familiar for the workings of a jet engine, what you are descriping is a 4-stroke, internal combustion (ie, automobile) engine.

    How can someone, anno 2005, be unfamiliar with anything? Tell me, how ignorant are you? You could at least have taken the effort to look it up: http://en.wikipedia.org/wiki/Jet_engine. Hell, you can even find how to make an atomic bomb on the 'net today. Hell, even some peoples code fuckups are on some site I heard...

  • (cs) in reply to RobIII

    Damn un-editable posts... Here's a thought for 2006: make posts editable [:P]

    Anyways. Forgot to mention this url...

  • Anon (unregistered) in reply to Anonymous

    Anonymous:
    The real WTF here is that the month and day are switched.

    That's about the only thing in that which DIDN'T make me go "WTF". Then again I come from Rightpondia.

  • Ryan Elisei (unregistered)

    Another observation for this section:

           'extract the parts of the date string
           theDay = Mid ( dateString, 1, 2  )
           theMonth = Mid ( dateString, 4, 2)
           theYear = Mid ( dateString, 7, 4 )

    As I understand it, Mid$() should be used for strings instead of resolving a varient with regular Mid().

    Also, might he not use Format() instead of hard-coded positions?

    e.g. : theDay = format(dateString, "dd")   'this would also solve any 0 padding issues

    [:O]

  • (cs) in reply to fstein
    Anonymous:
    13. In addition to #6, Increments for loop counter by 2 instead of 3 (6-3=2?)


    Incrementing the index variable in the loop is a WTF, but 2 is, ah, correct^Wleast wrong, since the next also increments by 1.  2 + 1 = 3.

    Sincerely,

    Gene Wirchenko

  • (cs) in reply to boohiss

    You're right.  "Consultants don't make the software, they make it more expensive."  For every 10 great programmers that are consulting, it just takes one guy like this to wreck their chances of getting a good gig.

  • nemo (unregistered) in reply to Not Telling
    Anonymous:
    brazzy:
    Anonymous:
    Too much consultant hate. Don't hate the player, hate the game. This awful code is not awful because it was done by a consultant, it is awful because it was done by someone who didn't realize that an IsDate function exists.


    Yeah, but it's extra awful because a guy got paid $250/h for writing it. I'm a consultant myself and it pisses me off because my company takes half that much, yet none of us would write crap like that.

    What you're looking at is the reason why IBM is the world's 3rd most valuable brand. It has an estimated value of over $50bn (the brand alone, not the company) because it allows you to charge $250/h for incompetent coders. Just like the world's most valuable brand allows you to charge three times the normal price for caffeinated, excessivly sparkly sugar water.


    here here!!
    Oh wait, I work for IBM.
    Ignorance is bliss, ask any of my blissful colleagues.



    Ahem. It's "hear, hear".

    The original form of this expression was hear him, which was usually repeated. This imperative was used to call attention to a speaker's words, and naturally developed the sense of a broad expression of favor.

  • (cs) in reply to XYZ

    Anonymous:
    Unfortunately this doesn't take account of the fact that years divisible exactly by 100 aren't leap years unless they are also divisible exactly by 400.

    Truly spoken, as I discovered when researching leap year for an events calendar I recently wrote.

    <FONT face="Courier New" size=2>private bool isLeapYear(int year)
    {
     return ((year % 4 == 0) && !(year % 100 == 0)) || (year % 400 == 0);
    }
    </FONT><FONT size=1>

    </FONT>
  • (cs) in reply to FredSaw
    FredSaw:

    Anonymous:
    Unfortunately this doesn't take account of the fact that years divisible exactly by 100 aren't leap years unless they are also divisible exactly by 400.

    Truly spoken, as I discovered when researching leap year for an events calendar I recently wrote.

    <font face="Courier New" size="2">private bool isLeapYear(int year)
    {
     return ((year % 4 == 0) && !(year % 100 == 0)) || (year % 400 == 0);
    }
    </font><font size="1"></font>



    Very nice.

    But let me offer two alternatives anyway:
    && has higher precedence than || so let's save parentheses

        // optimized for readability
        return
            year % 400 == 0 || // 2000, 2400, etc. are leap years
                year % 4 == 0 && // most other divisible-by-4 are leap years
                year % 100 != 0 // except for 2100, 2200, 2300, 2500...
        ;

        // optimized for speed
        return
            !( // faster to check for non-leap years
                year % 4 != 0 || // 75% of the time this short-circuits
                year % 100 == 0 && // 75% of the time this short-circuits
                year % 400 != 0
            );

  • (cs) in reply to Mika

    The programmer could skip a large number of lines by doing a

    If DateString Like "##/##/####" Then Valid=True

    somewhere in the code

  • (cs) in reply to Maurits

    Oops, == has higher precedence than both && and ||
    Fixed versions:

        // optimized for readability
        return
            (year % 400 == 0) || // 2000, 2400, etc. are leap years
                (year % 4 == 0) && // most other divisible-by-4 are leap years
                (year % 100 != 0) // except for 2100, 2200, 2300, 2500...
        ;

        // optimized for speed
        return
            !( // faster to check for non-leap years
                (year % 4) != 0) || // 75% of the time this short-circuits
                (year % 100 == 0) && // 75% of the time this short-circuits
                (year % 400 != 0)
            );

  • (cs) in reply to Maurits

    Thanks for applying the torque wrench, Maurits.  Noteworthy stuff.

    Maurits:
    return
            !( // faster to check for non-leap years
                (year % 4) != 0) || // 75% of the time this short-circuits
                (year % 100 == 0) && // 75% of the time this short-circuits
                (year % 400 != 0)
            );

    So, the third calculation fires -50% of the time? [:D][;)]

  • (cs) in reply to FredSaw
    FredSaw:

    Thanks for applying the torque wrench, Maurits.  Noteworthy stuff.

    Maurits:
    return
            !( // faster to check for non-leap years
                (year % 4) != 0) || // 75% of the time this short-circuits
                (year % 100 == 0) && // 75% of the time this short-circuits
                (year % 400 != 0)
            );

    So, the third calculation fires -50% of the time? [:D][;)]



    Actually I'm somewhat of an idiot, though my code is right....

    (year % 4 != 0) || // 75% of the time this will short-circuit
    // GIVEN THAT year % 4 == 0...
    (year % 100 == 0) && // 96% of the time (not 75%) this will short-circuit
    (year % 400 != 0)

    So... 75% of the time only one check is necessary
    25% * 96% = 24% of the time exactly two checks are necessary
    The remaining 1% of the time, all three checks are necessary
  • (cs) in reply to Maurits

    Compare to the readable solution:
    (year % 400 == 0) || // 0.25% of the time this will short-circuit
    // GIVEN THAT year % 400 != 0...
    (year % 4 == 0) && // very slightly less than 25% of the time, this will short-circuit
    (year % 100 != 0)

    0.25% of the time one check is necessary
    very slightly less than 99.75% * 25% = 24.9375% of the time, two checks are necessary
    very slightly more than 74.8125% of the time, all three checks are necessary

  • michael (unregistered) in reply to boohiss

    boohiss wrote:

    Too much consultant hate. Don't hate the player, hate the game.

    This awful code is not awful because it was done by a consultant, it is awful because it was done by someone who didn't realize that an IsDate function exists.

    Pfft. For $250/hr, I'd want someone who has enough clue to either know the function was already implemented, or failing that, to RTFM to find out if such a function existed!

  • (cs) in reply to Drak
    Drak:

    Anonymous:
    bit:
    I especially like the manually incremented FOR loop.

    I'm not sure I see the problem with the manual increment (beyond the poor documentation):  the code intends to only check positions 3 and 6 (2 and 5?? Where's my reference guide? anyway, the separator positions) within the string.  Sure, the author could have simply extracted mid(,3,) and (,6,) and duplicated the if statement, but either approach can be successful.

    What I worry about is seeing an assignment, rather than a comparison, in the if statement ...
       if Not ( seperator = "/" Or separator = "-" Or separator = "."  ) ...

     

    In basic '=' is both an assignment AND a comparison. The compiler figures out which you want. For example, this is valid (albeit a bit unreadable):

    a = (b = c)

    a will be 'true' if b equals c, and 'false' otherwise.

    Drak

     

    how does it do this ?

     

Leave a comment on “Your $2000 Function, Rebilled”

Log In or post as a guest

Replying to comment #:

« Return to Article