Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


#Actualmhagain

Posted 26 April 2013 - 06:57 AM

This block:

 

  for(...)
  {
    // list item?
    if(...)
    {
      //....
      opened = false;
      return true;  // intercept mouse event
    }
  }

 

Suggests usage of the for...if anti-pattern.  Now, it may not be, it probably isn't, but it is something to be aware of and watch out for.

 

rip-off is correct about this:

 

Have you considered declaring your variables on the line they are first used? It would avoid the problem of having an uninitialised variable.

 

It's a good habit to get into, and also has the good practice of limiting your variable scope to the narrowest possible.  If your first block of code, "p" does not need to exist outside of the loop, so it shouldn't.  This kind of basic stuff will help make your code more robust too.


#1mhagain

Posted 26 April 2013 - 06:56 AM

This block:

 

  for(...)
  {
    // list item?
    if(...)
    {
      //....
      opened = false;
      return true;  // intercept mouse event
    }
  }

 

Suggests usage of the for...if anti-pattern.  Now, it may not be, it probably isn't, but it is something to be aware of and watch out for.

 

rip-off is correct about this:

 

Have you considered declaring your variables on the line they are first used? It would avoid the problem of having an uninitialised variable.

 

It's a good habit to get into, and also has the good practice of limiting your variable scope to the narrowest possible.  If your first block of code, "p" does not need to exist outside of loop, so it shouldn't.  This kind of basic stuff will help make your code more robust too.


PARTNERS