- 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
VB programmers criticising a C programmer - and with just cause. I never thought I'd see that happen.
Admin
I never thought I'd VB that happen.
Admin
Wait, December doesn't have 32 days?
Damn discount calendars...
Admin
I 'C' what you did there.
Admin
Actually since the Earth's rotation is slowing there will be fewer days in the year which might cancel out the longer year caused by the Earth getting farther away from a reduced mass red giant sun.
Admin
Future-proofing is underrated. In corporate programming it's frequent to have a temporary one month solution operate for a decade.
Based on that, anything that isn't temporary could be running for millennia.
Admin
So C-loving Clyde still wins. 32 day December or 30 day December (possibly introduced by NYE hating puritans) and his code still works!
Admin
The real WTF (sorry!) is that when I first got to this article a few minutes ago, it said "1 comments".
Come on Alex, is a pluralisation check that complicated??
Admin
thats not a WTF, this is a WTF:
Admin
Long before the sun grows cold, we could develop some common sense and restructure the calendar as 13 months of 28 days each. With the occasional leap day of course. His code will keep running, everyone else has to rewrite. Instant competitive advantage!
It could happen.
OK maybe not the common sense part.
Never mind.
Admin
That's nothing. One very-slow SQL app would look up the names of the months, and the names of the days for every web page generated, just in case they changed since the last second.
Another app very carefully defined BitsPerByte = 8, just in case that ever changed. Of course none of the code was prepared for the change, but ....
Admin
Alex didnt make the software. ;)
Admin
The real WTF is that it took them half a day to figure out what was going on. It was obvious within 30 seconds what the code does.
Admin
All he has done is ensure he doesnt get any juicy contract work when the Pope does add that extra day on.
Admin
Sounds like something a bored programmer would come up with, not really a WTF.
TRWTF on the page today is the job ad for a "Christian professional Senior Systems Engineer". If someone is good at their job, what does it matter what their religion is?
Admin
The real WTF is that Jake writes "ease of coding in VB".
Jake, here.
unsigned int x; if (x>=0xC0000000) {...}
Translate that into VB please. With ease of coding of course!
Admin
You're not being fair, are you?
The requirements must have clearly stated "check if it is the last day of the year". Implemented as required.
What about a switch to a different calendar, maybe one that doesn't have twelve months, let alone 31 days in the last. Maybe one day the leap day will be added on at the end, like leap seconds are.
Admin
C developers are not immune to criticism.
Common crimes of C developers (not including common mistakes like using = for ==):
Feel free to add to this list...
Admin
The real WTF is this:
[quote]we had good reasons for choosing VB instead.[quote]
Admin
Write code to match your thought process, not just to match "what it's eventually doing anyway."
This code reads as "If, as of tomorrow, 'last year' would in fact be what 'this year' currently is". I probably would have written it "If tomorrow is 'next year'", but I can't criticize that.
Coding-style wise, I'd probably have assigned to a temporary variable instead of nesting function-calls, but that's also more "style" than something which can be validly criticized.
All the "future proofing" comments are just stupid, it's obviously /not/ what happened here.
Admin
Pim:
Dim x as Currency
If x > 3221225472 then ... End If
BTW wouldn't this be more efficient: bSkipYearCheck = Year((CVDate(datYrEnd_Dt) + 1)) - 1 = iYear
Admin
Admin
So that means it is complicated?
Admin
That's a perfectly acceptable way to do it, and the fact that it took you half a day to work it out is something you should be ashamed of. The same algorithm could also be adapted slightly to work for last day of the month, decade, and so on.
Admin
Admin
I'm one of those lucky guys who never had anything to do with VB, so I may be wrong, but maybe it has something to do with a test on the ISO year, which is not always the same as the calendar year of a date (see http://meta.wikimedia.org/wiki/Template:Isoyear). Maybe iYear is the ISO year, or the Year function converts it to the ISO year, or, er, I don't know, just some wild random guessing...
And otherwise, just ignore this, it's Friday afternoon, time to go home ;-)
Admin
Is that even legal? I guess they are not an equal opportunity employer.
Admin
Wait, that doesn't work for "zero comments", so first, subtract the number of comments from the first day of the year to see if the year stays the same.
Admin
I guess this is relevant:
So with <15 employees, it's legal (in the US at least).
Admin
Java problem with that?
(You have to say "Java" like a Canadian)
Admin
(And, as far as C is concerned, "byte" does not necessarily mean "8 bits". That's what "octet" is used for.)
Admin
But OK, for the balance, I have been guilty of assuming ASCII, even though I do know about EBCDIC and others. And I assume that sizeof(unsigned) == sizeof(signed). You mean it doesn't have to be? "not taking advantage of C99 features" Why is that a crime? If I have to program in C (not C++), I try to be as generic as possible, deliberately avoiding features like // comments and on-the-fly var declarations like for (int i = 0;....
Admin
I'd add "assume the character set is ASCII".
Admin
Admin
"Requirements"? "Clearly stated"? You've never done Rapid Application Development before, have you? (That, or I gets a woooosh.)
Admin
Avoid // comments?
Ugh, I can't even say how much I hate it when people do /* blah */ as it prevents simply commenting out a block of code. Yes, I know, I can just wrap it in a preprocessor #if instead.
But seriously, I've yet to come across a C compiler that doesn't support //
Admin
QuickC.
Admin
Admin
Ethiopia has such a calendar now. In fact, their Ministry of Culutre and Tourism uses the slogan "13 Months of Sushshine."
Of course 13 x 28 = 364 so JustSayin's "occasional leap day" would likely have to occour every year, but that's another matter.
Admin
What happens at the End of Days, when there IS no tomorrow to test the year of?
CATCHPA: "verto", which my Unabridged Dictionary states is a disorder where your toes are permanently vertical.
Admin
That's what I was thinking. It's overkill in the example given and legitimately a WTF, but I've used a similar pattern of letting the system time libraries do the hard work of figuring out the end of the month for me. It's quite possible that's where the WTF came from -- he was thinking of cases where there are lots of date-time gotchas and instead applied it to a case where the date rules are quite simple.
Admin
My brother's original, legal birth certificate lists his day of birth as December 32nd.
Admin
You have to look at the value to time ratio. There's ever only going to be one time when the singular is used while there's all kinds of times when the plural is going to be used. Why code for the exception instead of the rule?
Admin
Same Clyde as here?
Admin
Admin
Admin
A little threadjack (a WTF of my own)...
You might want to be careful with that spelling... When I wanted to suggest my favourite feature to Gmail today, I was told "We are unable to provide email support in your language at this time". They did offer me the choice of switching from British (which apparently their support team can't read) to American, though...Admin
Admin
(frantically searching through my bookcases now... where did I leave my K&R? I must have it somewhere! Don't tell me I put it in a box in the cellar... Oh look, the Quick C programmer's guide! Aw, that can wait. K&R, where are you hiding?)
Admin
It took half a day to figure that out?