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!


#ActualMatt-D

Posted 23 June 2013 - 03:33 PM

As for the original question, I agree with the others; two relevant principles here:

  • Minimizing Variable Scope
    Recall that programming is about communication with the maintainer of the code, more than about communication with the compiler.
    In order to help the maintainer as much as possible, we should make sure variables and other identifiers have as small a scope as possible.
    The scope of a variable is the physical program text in which it is visible. The smaller to scope of each variable, the fewer the live variables at any particular point in the code.

     
  • Reduce Scope of Variable
    // well, OK, this one is a refactoring used to follow the aforementioned principle :-)

     

    You have a local variable declared in a scope that is larger than where it is used

    Reduce the scope of the variable so that it is only visible in the scope where it is used

     


#4Matt-D

Posted 23 June 2013 - 03:32 PM

As for the original question, I agree with the others; two relevant principles here:

  • Minimizing Variable Scope
    Recall that programming is about communication with the maintainer of the code, more than about communication with the compiler.
    In order to help the maintainer as much as possible, we should make sure variables and other identifiers have as small a scope as possible.
    The scope of a variable is the physical program text in which it is visible. The smaller to scope of each variable, the fewer the live variables at any particular point in the code.

     
  • Reduce Scope of Variable
    // well, OK, this one is a refactoring, used to follow the aforementioned principle :-)

     

    You have a local variable declared in a scope that is larger than where it is used

    Reduce the scope of the variable so that it is only visible in the scope where it is used

     


#3Matt-D

Posted 23 June 2013 - 03:32 PM

As for the original question, I agree with the others; two relevant principles here:

  • Minimizing Variable Scope
    Recall that programming is about communication with the maintainer of the code, more than about communication with the compiler.
    In order to help the maintainer as much as possible, we should make sure variables and other identifiers have as small a scope as possible.
    The scope of a variable is the physical program text in which it is visible. The smaller to scope of each variable, the fewer the live variables at any particular point in the code.

     
  • Reduce Scope of Variable
    // well, OK, this one is a refactoring :-)

     

    You have a local variable declared in a scope that is larger than where it is used

    Reduce the scope of the variable so that it is only visible in the scope where it is used

     


#2Matt-D

Posted 23 June 2013 - 03:31 PM

As for the original question, I agree with the others; two relevant principles here:

  • Minimizing Variable Scope
    Recall that programming is about communication with the maintainer of the code, more than about communication with the compiler.
    In order to help the maintainer as much as possible, we should make sure variables and other identifiers have as small a scope as possible.
    The scope of a variable is the physical program text in which it is visible. The smaller to scope of each variable, the fewer the live variables at any particular point in the code.

     
  • Reduce Scope of Variable
    // well, OK, this one is a refactoring :-)

#1Matt-D

Posted 23 June 2013 - 03:30 PM

As for the original question, I agree with the others; two relevant principles here:


PARTNERS