Programming quiz: Fix the Y2K bug

greenspun.com : LUSENET : TimeBomb 2000 (Y2000) : One Thread

Y2K Programming Quiz

I've posted this before, but it's too good not to post again. Take the quiz and fix lines of code that have y2k bugs.

-- John Ainsworth (ainsje00@wfu.edu), December 07, 1999

Answers

EXCELLENT piece of work! The examples given here can (and do) occur in virually every system and in every programming language.

Keep in mind, that when code as found in these examples fails, it does not fail with a bang. It is silent -- and very, very fast. Databases of every kind imaginable (and unimaginable) will be corrupted as a result of faulty or non-remediated code.

Frankly, fixing the code is the easy part -- if you know what you're doing. Finding what to fix, deciding how to fix, and testing the fix are the time consuming tasks.

T-24 tic.toc.tic.toc.tic.............

-- TA (sea_spur@yahoo.com), December 07, 1999.


Cool , I got 6 out of 9 right and I flunked progaming in tech school.

-- Jeff (Jefsta@work.play), December 07, 1999.

Sure hope most Y2K programmers weren't guessing.

-- TA (sea_spur@yahoo.com), December 07, 1999.

8 out of 9, and I contest the answer to question number 4. It is listed as No (sort of) and should be Yes.

As shown, the code will not work correctly in 2000 (or in any other year) since it does not correctly compute leap years. The fact that the error does not have a negative impact in 2000 is a fortuitous circumstance and not correct behavior.

-- Paul Neuhardt (neuhardt@ultranet.com), December 07, 1999.


No example had enough information to know whether you are dealing with date data or just a field named y1, y2, etc. Without library code, I don't know whether the tm_year is a real system call or a call to a programmer-defined subroutine returning gosh knows what. The code apparently presumes that the data storage objects (wherever they are) can hold values over 99, which is sure not a given. Without the definitions, I don't know what you have here.

I've been doing Y2k work since 1994 and programming since 1974 or so. This quiz is a joke.

-- bw (home@puget.sound), December 07, 1999.



I got 4 out of 9 and consider myself lucky! Can you say INSUFFICIENT DATA!?!?! There are no data layouts or actual files to examine. If people are only looking this far into fixing Y2K, GOD help us! There are LOTS of assumptions being made.

-- Jim (x@x.x), December 07, 1999.

To those who thought there was insufficient information on many of the examples, you are correct. Answer those questions "Yes" and you will almost always be correct. It's a test designed to make you look dumb by telling you you are wrong when you can't be right except by chance. It's a common ploy of "holier-than-thou" testers who's aim is to make the subject feel stupid and not to test knowledge.

Using this guessing method was the way I scored 8 out of 9.

-- Paul Neuhardt (neuhardt@ultranet.com), December 07, 1999.


Moderation questions? read the FAQ