- 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
The fact that he even gets paid to write code like this is a big WTF.
Admin
[pi]
Admin
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.
Admin
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
Admin
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.
Admin
Uh... so what were those languages in wide use before C that were more expressive and efficient? Fortran? COBOL??
Admin
Lisp or Smalltalk i guess, even though "wide use" would be highly debatable.
Admin
Hey Mr Blissful, that would be "hear hear"
how amusing
Admin
<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>
<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.
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.
Admin
<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>
Admin
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).
Admin
PL/1 comes to my mind.
Admin
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 :-)
Admin
Sorry, this market is price-driven, quality doesn't matter. Therefore: I can offer the same quality of code for 80% of the price. ;-)
Admin
http://www.timeanddate.com/date/leapyear.html
http://aa.usno.navy.mil/faq/docs/leap_years.html
http://scienceworld.wolfram.com/astronomy/LeapYear.html
http://en.wikipedia.org/wiki/Leap_year
Admin
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.
Admin
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!
Admin
I especially like the manually incremented FOR loop.
Admin
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 = "." ) ...
Admin
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 :)
Admin
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?
Admin
ON ERROR fuck it
Admin
Stop is also in VB
http://courses.nnu.edu/cs226bm/appendixA.htm
Admin
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
Admin
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.
Admin
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?
Admin
I'll have to confirm that. Just tested it in VB6 and it just breaks to the debugger.
Admin
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 :-/)
Admin
Lets just say I won't get out of bed for any less than €25 p/h [:P]
Admin
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.
Admin
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.....
Admin
$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! :'(
Admin
how about:
"-6-31.WTF?" [:)]
Admin
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.
Admin
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...
Admin
Damn un-editable posts... Here's a thought for 2006: make posts editable [:P]
Anyways. Forgot to mention this url...
Admin
That's about the only thing in that which DIDN'T make me go "WTF". Then again I come from Rightpondia.
Admin
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]
Admin
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
Admin
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.
Admin
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.
Admin
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)
</FONT>{
return ((year % 4 == 0) && !(year % 100 == 0)) || (year % 400 == 0);
}
</FONT><FONT size=1>
Admin
Very nice.
But let me offer two alternatives anyway:
&& has higher precedence than || so let's save parentheses
Admin
The programmer could skip a large number of lines by doing a
If DateString Like "##/##/####" Then Valid=True
somewhere in the code
Admin
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)
);
Admin
Thanks for applying the torque wrench, Maurits. Noteworthy stuff.
So, the third calculation fires -50% of the time? [:D][;)]
Admin
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
Admin
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
Admin
boohiss wrote:
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!
Admin
how does it do this ?