Kristopher has the pleasure of working with Robert, The Infallible Programmer. Robert (his earthly name) is actually one of the world's two programmers who have never coded a single bug. The other bug-free programmer, though not infallible, is the guy who writes all of those "Hello World" examples.

This is not to say that the Code of Robert is bug-free. As a worldly programmer, Robert is constrained to worldly tools created by fallible programmers, and it is within these tools that the defects exist, and not His code. To Him, nothing is "real" in the sense of, "if we used a REAL database, this would work," or "if we used a REAL operating system, this wouldn't crash." But alas, He contends that no "real" tools exist on the marketplace yet: "everything out there is made by a bunch of idiots!"

But let's get back to Kristopher, who joined the company several months back. As an intern, Kristopher is in no position to question anything produced by Robert. Nor is anyone else: Robert is also the star-developer and His word is final. Besides, how could one possibly question the Code of Robert, anyway? It's infallible, after all.

Kristopher thought it would be an interesting exercise to show what exactly infallible code looks like. This example of the Code of Robert was found in the session termination subroutine of one of their web applications. Kristopher hasn't quite figured out what PHP, Postgres, Apache, or Linux bug this "trying the same database query 5,000 times until it works" code is working around, but I'll bet it's a pretty serious one ...

// Try 5000 times to make sure that this stupid thing // was deleted. This crap is such a toy. while ( !$bDeleted && $iTimes < 5000 ) { $iTimes++; //does session exist? $sSQL = "SELECT * FROM sessions " . "WHERE s_user_id = " . $user_id . ""; if ( !$qryObj->Exec( $sSQL ) ) continue; //failed, try again if ( $qryObj->NumRows() == 0 ) { //finally, deleted! $bDeleted = true; break; } //delete session $sSQL = "DELETE FROM sessions " . "WHERE s_user_id = " . $user_id . ""; if ( !$qryObj->Exec( $sSQL ) ) continue; //failed, try again } if ( !$bDeleted ) { trigger_error( "Delete failed.", E_USER_ERROR ); die(); }

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!