Stupidest Error

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Stupidest Error

Post 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&#39;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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Rare. Very rare.

I actually can't remember what the error was when this happened last.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Almost always a missing semicolon. My IDE matches my braces and parentheses, but it does not add semicolons.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Missing a bracket off statements like this

Code: Select all

if(!empty($somVar)
I always always do that!

Also semi colons
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Pimptastic wrote:Missing a bracket off statements like this

Code: Select all

if(!empty($somVar)
I always always do that!
Ditto. But it takes like 2 seconds to fix after reading the parse error.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Post 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.
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

Here is how I deal with the

Code: Select all

if(!isset($var)
  die;
error - through strict white space:

Code: Select all

if ( ! isset($var) )
  die;
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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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
{
    //
}
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

You know, I've never had that happen to me before. Never ever ever. Hmm...
Post Reply