Page 1 of 1
Stupidest Error
Posted: Sun Aug 06, 2006 8:45 pm
by LiveFree
We've all done it; we stay up until 12 or so at night to finish a project. We then run/test it and find we have an error. And yet no matter how much we look through our complicated classes and scripts; we just CANT find the error.
So you get up and get a cup of coffee, but as soon as you sit down you realize "Ah <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> I forgot a parentheses!".
How many times does that happen to you and what form do the errors take?
Posted: Sun Aug 06, 2006 8:46 pm
by feyd
Rare. Very rare.
I actually can't remember what the error was when this happened last.
Posted: Sun Aug 06, 2006 8:58 pm
by Ambush Commander
I don't think it's in the form of a parentheses... any editor worth its salt should warn you about it (or the parse error easy to interpret).
The last time a bug took a long time for me to figure out was caused by some weirdness involving the existence of $this even when you do static class calls.
Posted: Sun Aug 06, 2006 9:17 pm
by RobertGonzalez
Almost always a missing semicolon. My IDE matches my braces and parentheses, but it does not add semicolons.
Posted: Mon Aug 07, 2006 3:37 am
by JayBird
Missing a bracket off statements like this
I always always do that!
Also semi colons
Posted: Mon Aug 07, 2006 4:21 am
by s.dot
Pimptastic wrote:Missing a bracket off statements like this
I always always do that!
Ditto. But it takes like 2 seconds to fix after reading the parse error.
Posted: Mon Aug 07, 2006 8:35 am
by MrPotatoes
organized code and a syntax highlighter is your best friend. it's really not that hard but this really limits these tupid errors to 5min max code search
Posted: Mon Aug 07, 2006 8:50 am
by Chris Corbyn
Syntax errors, notices, warnings etc I always fix in like 10 seconds. You can't possibly require a coffee for those errors because you should be using an editor that highlights them and also have full error reporting on PHP.
Logic errors.... those can drive you nuts and yes, a cup of coffee and some time away from the computer doing something compltely unrelated usually helps... sometimes you need to clear your head when you've started looking down the wrong path.
Posted: Mon Aug 07, 2006 9:02 am
by MrPotatoes
d11wtq wrote:Syntax errors, notices, warnings etc I always fix in like 10 seconds. You can't possibly require a coffee for those errors because you should be using an editor that highlights them and also have full error reporting on PHP.
Logic errors.... those can drive you nuts and yes, a cup of coffee and some time away from the computer doing something compltely unrelated usually helps... sometimes you need to clear your head when you've started looking down the wrong path.
oh no doubt.
if it's been longer than 2 days for any logic error my personal choice is to start all the way over lol
Posted: Mon Aug 07, 2006 10:00 am
by Chris Corbyn
MrPotatoes wrote:oh no doubt.
if it's been longer than 2 days for any logic error my personal choice is to start all the way over lol
Same.
I take a similar stance when it comes to improving other people's code. I'll tend to overview what it does then write my own rather than taking the exisiting code and modifying it. A clean start is always good.
Posted: Mon Aug 07, 2006 11:26 am
by MrPotatoes
i've tried. i've honestly tried to modify other peoples' code and it usually ends up terribly and i never learn my lesson.
very few times have i successfully worked with other peoples' code. i tend to see what it does and make a much more simpified version. my template is the only system that i have re-coded and working successfully.
Posted: Mon Aug 07, 2006 12:01 pm
by Todd_Z
Here is how I deal with the
error - through strict white space:
Make sure the function has no whitespace in the params list, and the if parens always has a space after and before the brackets.
Should save you about 3-4 seconds.
Posted: Mon Aug 07, 2006 12:05 pm
by Chris Corbyn
A good way to prevent to extremely common assignment vs comparison issue:
Code: Select all
//I mean
// if ($foo == 42)
if ($foo = 42)
{
//blah, always true of course
}
is to place the constant on the left-hand side ... looks wrong though.
Code: Select all
if (42 = $var) //Error... can't change value of constant 42
{
//
}
Posted: Mon Aug 07, 2006 12:07 pm
by Ambush Commander
You know, I've never had that happen to me before. Never ever ever. Hmm...