Version 1.2

Top  Previous  Next

Version 1.2

Localize Module Variables: This refactoring analyzes the way that private module-level variables are referenced,determines the optimum scope of each private module-level variable based on its usage within the module, and lets you customize and execute any/all the variable moves with great ease.

 

Localize Module Variables is not an officially-catalogued refactoring, so far as this author knows, but it meets the definition of a refactoring: it should not change the behavior of your code. Here's how it works:

 

1.CodeShine scans the module, and for each private, module-level variable, it determines which routines reference the variable.
2.CodeShine makes a suggestion based on the number of routines that reference each variable.
if no routines reference the variable, CodeShine suggests that you delete it.
if exactly one routine references the variable, then CodeShine suggests that you move the variable into that routine, to improve encapsulation and clarity
if multiple routines reference the variable, then CodeShine suggests that you leave it alone
3.All of CodeShine's suggestions will be logically correct, in that clicking Execute will result in code that will compile and behave as before; however, some of them may not correspond with your intentions for the future usage of these variables (CodeShine will suggest that you delete an unreferenced variable, for instance, while you might know that you're just about to write code that will reference that variable). Because of this, you have the opportunity to change/disable each  action individually.
 

This  is a great tool for simplifying the structure of a module, especially if "the last programmer" wasn't too careful about encapsulation. It is also can be useful after you've made significant changes to a module - if you've deleted or consolidated several routines, for instance, you may now have one or more module-level variables that can be "localized." If a private module-level variable isn't referenced in code, then the suggestion is to delete it; if it is referenced by only one routine, then the suggestion is to move it into the routine that references it. If it is referenced by more than one routine, then it is left alone. The interface allows you to control the process variable-by-variable:

 

LocalizeModuleVariables

 

A greatly improved interface for Extract Method:

 

Introduce Explaining Variable can be used to create a module-level explaining variable, not just a local as in Version 1.1.

 

There were a number of miscellaneous bug fixes.