Selasa, Januari 24, 2006

A Little Silly Mistake

Today i got some phone call from someone who order me to make a small program on handling incoming sms. He told me that my program didn't work as expected. Damn, after doing some checking on my code, I have found that I only did a small mistake ( yes, i just misplace the argument of a function). I code using PHP, and use 1 function for 3 different case. The problem is, the argument passed to the function does really matter.
Consider the following code :
function updateFoo($foo, $bar=1, $bar2=""){}
when i gave 1 argument to the function, i will do A, when the arguments is 2, i will do B, etc
The problem happened, because i wrongly misplaced second argument, it should be placed in when condition is X, not when condition is Y.
The result, because the function is trying to update database based on the argument, the updating process is then failed, while other program expect it to be updated, otherwise the record will be processed again #-o (really silly huh.. )
Thank God that I noticed this during debugging.. :P
~a careless coder

Tidak ada komentar: