Comment On Foolproof Future-Proofing

"We had a coder for our project named Clyde," Robert B. writes, "who would have been much happier coding in C, but we had good reasons for choosing VB instead. To make up for the ease of coding in VB, Clyde would eschew the simple way of doing things. No calls to well-defined common routines for him; no, he would code deeply inscrutable functions to accomplish even the simplest tasks. [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5Next »

Re: Foolproof Future-Proofing

2009-04-03 09:03 • by java.lang.Chris;
VB programmers criticising a C programmer - and with just cause. I never thought I'd see that happen.

Re: Foolproof Future-Proofing

2009-04-03 09:08 • by NSCoder
253423 in reply to 253422
I never thought I'd VB that happen.

Re: Foolproof Future-Proofing

2009-04-03 09:08 • by snoofle
Wait, December doesn't have 32 days?

Damn discount calendars...

Re: Foolproof Future-Proofing

2009-04-03 09:09 • by Anon Ymous
253425 in reply to 253423
NSCoder:
I never thought I'd VB that happen.


I 'C' what you did there.

Re: Foolproof Future-Proofing

2009-04-03 09:10 • by Badastronomy (unregistered)
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.

Re: Foolproof Future-Proofing

2009-04-03 09:12 • by Simon (unregistered)
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)
253430 in reply to 253426
Badastronomy:
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.


So C-loving Clyde still wins. 32 day December or 30 day December (possibly introduced by NYE hating puritans) and his code still works!

Re: Foolproof Future-Proofing

2009-04-03 09:14 • by Bobbo
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)
253433 in reply to 253431
Bobbo:
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??


thats not a WTF, this is a WTF:

Re: Foolproof Future-Proofing

2009-04-03 09:17 • by Just Sayin (unregistered)
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)
253436 in reply to 253431
Bobbo:
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??


Alex didnt make the software. ;)

Re: Foolproof Future-Proofing

2009-04-03 09:24 • by Alex (unregistered)
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.

Re: Foolproof Future-Proofing

2009-04-03 09:26 • by Alan (unregistered)
All he has done is ensure he doesnt get any juicy contract work when the Pope does add that extra day on.

Re: Foolproof Future-Proofing

2009-04-03 09:28 • by CaptainSmartass
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?

Re: Foolproof Future-Proofing

2009-04-03 09:28 • by Pim
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!

Re: Foolproof Future-Proofing

2009-04-03 09:33 • by Warren (unregistered)
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.

Re: Foolproof Future-Proofing

2009-04-03 09:35 • by Buddy (unregistered)
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...

Re: Foolproof Future-Proofing

2009-04-03 09:36 • by SomeDude (unregistered)
The real WTF is this:

[quote]we had good reasons for choosing VB instead.[quote]

Re: Foolproof Future-Proofing

2009-04-03 09:38 • by someguy (unregistered)
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)
253447 in reply to 253442
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)
253448 in reply to 253441
CaptainSmartass:
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?

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)
253449 in reply to 253436
laoreet:
Bobbo:
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??


Alex didnt make the software. ;)


So that means it is complicated?

Re: Foolproof Future-Proofing

2009-04-03 09:47 • by Davy (unregistered)
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.

Re: Foolproof Future-Proofing

2009-04-03 09:48 • by kastein
253451 in reply to 253444
Buddy:
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...

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

Re: Foolproof Future-Proofing

2009-04-03 09:48 • by Just me (unregistered)
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)
253453 in reply to 253441
CaptainSmartass:
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?


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)
253456 in reply to 253431
Bobbo:
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??
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)
253457 in reply to 253453
Anon:
CaptainSmartass:
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?


Is that even legal? I guess they are not an equal opportunity employer.


I guess this is relevant:

Title VII of the Civil Rights Act of 1964 and the Americans with Disabilities Act (ADA) cover all private employers, state and local governments, and education institutions that employ 15 or more individuals. These laws also cover private and public employment agencies, labor organizations, and joint labor management committees controlling apprenticeship and training.


So with <15 employees, it's legal (in the US at least).

Re: Foolproof Future-Proofing

2009-04-03 09:58 • by jobrahms
253458 in reply to 253425
Anon Ymous:
NSCoder:
I never thought I'd VB that happen.


I 'C' what you did there.


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)
253459 in reply to 253435
Ancient_Hacker:
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 ....
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.)

Re: Foolproof Future-Proofing

2009-04-03 10:04 • by Pim
253460 in reply to 253444
Buddy:
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...
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)
253462 in reply to 253444
Buddy:
C developers are not immune to criticism.

Common crimes of C developers (not including common mistakes like using = for ==):

[...]
* 'A' - 'Z', 'a' - 'z', '0' - '9' are continuous (guilty!)
[...]

Feel free to add to this list...
Umm... '0'-'9' are guaranteed to be contiguous in C.

I'd add "assume the character set is ASCII".

Re: Foolproof Future-Proofing

2009-04-03 10:08 • by Pim
253463 in reply to 253459
Ken B:
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.)

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)
253464 in reply to 253443
Warren:
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.


"Requirements"? "Clearly stated"? You've never done Rapid Application Development before, have you? (That, or I gets a woooosh.)

Re: Foolproof Future-Proofing

2009-04-03 10:13 • by Kermos
253465 in reply to 253460
Pim:
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;....


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:19 • by Pim
QuickC.

Re: Foolproof Future-Proofing

2009-04-03 10:23 • by Ken B (unregistered)
253467 in reply to 253460
Pim:
Buddy:
C developers are not immune to criticism.

Common crimes of C developers (not including common mistakes like using = for ==):

[...]
* non-portable assumptions - 8 bits per byte,
[...]
There are 8 bits in an byte, silly.
Don't tell me you confuse bytes with chars?
No, there are not necessarily 8 bits in a byte as far as C is concerned. A byte is defined as:
byte
addressable unit of data storage large enough to hold any member of the basic character set of the execution environment
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
253468 in reply to 253434
Just Sayin:
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.


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.

Re: Foolproof Future-Proofing

2009-04-03 10:26 • by Ross Presser (unregistered)
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
253470 in reply to 253450
Davy:
The same algorithm could also be adapted slightly to work for last day of the month, decade, and so on.


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.

Re: Foolproof Future-Proofing

2009-04-03 10:29 • by JJ (unregistered)
My brother's original, legal birth certificate lists his day of birth as December 32nd.

Re: Foolproof Future-Proofing

2009-04-03 10:30 • by MrsPost
253473 in reply to 253431
Bobbo:
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??

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?

Re: Foolproof Future-Proofing

2009-04-03 10:31 • by Pol

Re: Foolproof Future-Proofing

2009-04-03 10:32 • by MrsPost
253475 in reply to 253441
CaptainSmartass:
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?

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)
253476 in reply to 253463
Pim:
Ken B:
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.)

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.
from the ISO documentation on the C language (I am using ISO/IEC 9899:TC2)
3.6
byte
addressable unit of data storage large enough to hold any member of the basic character set of the execution environment
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)
253477 in reply to 253431
A little threadjack (a WTF of my own)...
Bobbo:
[...]pluralisation check that complicated??

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)
253479 in reply to 253425
Anon Ymous:
NSCoder:
I never thought I'd VB that happen.


I 'C' what you did there.

A vblbuttic joke.

Re: Foolproof Future-Proofing

2009-04-03 10:44 • by Pim
(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?)

Re: Foolproof Future-Proofing

2009-04-03 10:48 • by Deke (unregistered)
It took half a day to figure that out?
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5Next »

Add Comment