Tuesday, October 28, 2008

The double-while pattern

Ok, this started with a mysql bug with foreign keys : the schema just crashes randomly with syntax errors, but "sometime" succeeds.

No problem, here comes the "While Pattern".

Problem to solve :
A program crashes randomly but sometimes work

Solution :

boolean success;
do {
try {
success = true;
} catch (... well anything) {
} while (!success);

Bonus point : the low voltage version with a 1sec sleep after the buggy program call.

Stay tuned for the double while pattern ;-)

No comments: