| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Page 5 | Next » |
|
VB programmers criticising a C programmer - and with just cause. I never thought I'd see that happen.
|
|
I never thought I'd VB that happen.
|
|
Wait, December doesn't have 32 days?
Damn discount calendars... |
Re: Foolproof Future-Proofing
2009-04-03 09:09
•
by
Anon Ymous
|
I 'C' what you did there. |
|
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.
|
|
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. |
Re: Foolproof Future-Proofing
2009-04-03 09:14
•
by
SR
(unregistered)
|
So C-loving Clyde still wins. 32 day December or 30 day December (possibly introduced by NYE hating puritans) and his code still works! |
|
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?? |
Re: Foolproof Future-Proofing
2009-04-03 09:17
•
by
Schlong
(unregistered)
|
thats not a WTF, this is a WTF: |
|
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. |
Re: Foolproof Future-Proofing
2009-04-03 09:18
•
by
Ancient_Hacker
(unregistered)
|
|
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 .... |
Re: Foolproof Future-Proofing
2009-04-03 09:18
•
by
laoreet
(unregistered)
|
Alex didnt make the software. ;) |
|
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.
|
|
All he has done is ensure he doesnt get any juicy contract work when the Pope does add that extra day on.
|
|
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? |
|
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! |
|
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. |
|
C developers are not immune to criticism.
Common crimes of C developers (not including common mistakes like using = for ==): * using gets and strtok - evil * using atoi, atol, atof without validating input * intimidated by qsort to the point of writing their own sort routines * non-portable assumptions - 8 bits per byte, two's complement arithmetic, sizeof(short) < sizeof(int) < sizeof(long), sizeof(signed type) == sizeof(unsigned type), 'A' - 'Z', 'a' - 'z', '0' - '9' are continuous (guilty!) * letting system handle memory deallocations (guilty!) * not taking advantage of C99 features (guilty!) Feel free to add to this list... |
|
The real WTF is this:
[quote]we had good reasons for choosing VB instead.[quote] |
|
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. |
Re: Foolproof Future-Proofing
2009-04-03 09:39
•
by
Anonymous Coward
(unregistered)
|
|
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 |
Re: Foolproof Future-Proofing
2009-04-03 09:41
•
by
Fred
(unregistered)
|
Obviously they don't want someone who is good at their job. They want someone who is infected with the same meme as they are, to help them further the spread of the infection. |
Re: Foolproof Future-Proofing
2009-04-03 09:46
•
by
D C Ross
(unregistered)
|
So that means it is complicated? |
|
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.
|
I'll bite: * Preprocessor abuse (I should be on death row...) * ?: the best, worst operator on the planet (guilty) * bitwise vs logical NOT (~ != !) confusion * not checking return values for failure |
|
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 ;-) |
Re: Foolproof Future-Proofing
2009-04-03 09:52
•
by
Anon
(unregistered)
|
Is that even legal? I guess they are not an equal opportunity employer. |
Re: Foolproof Future-Proofing
2009-04-03 09:55
•
by
Ken B
(unregistered)
|
Just add the number of comments to the next-to-last day of the year, and see if the year changes. 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. |
Re: Foolproof Future-Proofing
2009-04-03 09:57
•
by
Anon
(unregistered)
|
I guess this is relevant:
So with <15 employees, it's legal (in the US at least). |
Java problem with that? (You have to say "Java" like a Canadian) |
Re: Foolproof Future-Proofing
2009-04-03 09:58
•
by
Ken B
(unregistered)
|
The C language defines CHAR_BITS to be the number of bits per character, because it's not always 8. (And, as far as C is concerned, "byte" does not necessarily mean "8 bits". That's what "octet" is used for.) |
There are 8 bits in an byte, silly. Don't tell me you confuse bytes with chars? 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;.... |
Re: Foolproof Future-Proofing
2009-04-03 10:06
•
by
Ken B
(unregistered)
|
Umm... '0'-'9' are guaranteed to be contiguous in C. I'd add "assume the character set is ASCII". |
You're not really a C programmer, are you? Neither "byte" nor "octet" are defined C types. A char is not a byte, and nobody has yet tried to say that a char always has 8 bits. |
Re: Foolproof Future-Proofing
2009-04-03 10:11
•
by
Anonymous Coward
(unregistered)
|
"Requirements"? "Clearly stated"? You've never done Rapid Application Development before, have you? (That, or I gets a woooosh.) |
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 // |
Re: Foolproof Future-Proofing
2009-04-03 10:23
•
by
Ken B
(unregistered)
|
No, there are not necessarily 8 bits in a byte as far as C is concerned. A byte is defined as: In fact, C defined CHAR_BITS specifically because it may be more than 8. |
Re: Foolproof Future-Proofing
2009-04-03 10:26
•
by
ContraCorners
|
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. |
|
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. |
Re: Foolproof Future-Proofing
2009-04-03 10:28
•
by
Erasmus Darwin
|
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. |
|
My brother's original, legal birth certificate lists his day of birth as December 32nd.
|
I was writing something that also had a singular/plural text issue. I just decided on different wording so it didn't need that particular phrasing. 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? |
It's like the various businesses that have the Christian fish symbol. I take it as a warning, kind of like the "Intel Inside" stickers. |
Re: Foolproof Future-Proofing
2009-04-03 10:37
•
by
Ken B
(unregistered)
|
from the ISO documentation on the C language (I am using ISO/IEC 9899:TC2) C doesn't have a type of "byte", but it does define the term. It also refers to other ISO documents, one of which defines "octet". |
Re: Foolproof Future-Proofing
2009-04-03 10:38
•
by
IByte
(unregistered)
|
|
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... |
Re: Foolproof Future-Proofing
2009-04-03 10:41
•
by
blindman
(unregistered)
|
A vblbuttic joke. |
|
(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?) |
|
It took half a day to figure that out?
|
| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Page 5 | Next » |