An Infinite Number of Monkeys

So there we were, tri-programming (pair programming with 3 people instead of 2), working on a particularly vexing problem. A data structure had changed in a file format. We had a tool which read this file that was crashing, but we didn't know exactly what the change was. What we knew was that a particular byte offset had changed from 48 bytes to some unknown number.

What we DID have was a set of comprehensive unit tests. Unit tests which ran easily in mere moments, and which, thankfully, crashed dismally when reading the new file format.

 

So in short, we knew we had to change our magic 48 to something better. We'd been staring at the file format for a good 20 minutes or so, trying to count out the bytes, based off of the code that generated it. Trying to figure out what hidden things our file-writing code was doing to the data to cause it to not fit what we thought was correct.

My cohort had even printed a byte dump of the file and was bent, straining, stroking his brow, over it.

"We need to figure out what each of these is", he said, pointing to the paper. "Then find the next record, and count the bytes. That's how we did it the first time."

"Ok, well, here's the next record right here." I replied, pointing to the paper, "See, there's the 4 for the next record."

"Well, that's 10 more bytes then, it must be 10!" our third said.

We all nodded in agreement, changed our 48 to 58 and reran the tests...

Fail.

"Damn!" My friend with the paper exclaimed, and returned to converting decimal to hex via his calculator.

"Try 42." My other friend said. He always liked to try 42 because of course, it was the meaning of everything.

I typed in 42 as a joke, and reran. Fail. Our calculating friend glared up from his paper and grunted something derisively.

"How about we start at 48, and work our way up till we find it." I said.

"NO!" The human calculator retorted. "That's guessing! And Guessing SUCKS! We need to KNOW! Knowing is BETTER!"

He was of course right, and we were properly humbled. He continued to calculate.

"Argh.. that's not the size! It's the netmask." He mumbled.

"Oh wait, it is the size. Then how many bytes until the end of that?" He mumbled again.

Bored, I typed into the program '57'. Run. Fail.

"Are you sure that's a float and not a double?" He asked.

"Yep, it's right there" I said, pointing to the screen.

I typed '56'. Run. Fail.

"How big is a float?" He asked. We responded.

I typed '55'. Run. Fail.

"Well if it's that big, then..." he continued.

'54'. Fail. '53' Fail.

"Oh, this is all wrong. I need to start over." He grumbled.

I typed '52' - - - PASS!

My other friend over my shoulder chuckled.

And so... what this proved is that:

Given proper and sufficient functional tests, an infinite number of monkeys, and an infinite number of computers, it's TRUE... They WILL write the software you want! :)

(Ok, long joke, short punchline, so sue me. ;D)

PowerCard | TreeTracker | Contact Us