-
Notifications
You must be signed in to change notification settings - Fork 311
Description
Justification
As a codebase grows, the probability of a naming conflict arising among public subs and functions as external modules and/or new modules are added increases quickly. There is a dynamic tension between using simple straightforward names for subs and functions within a module and those names having already been chosen in another code-base's modules which now must be merged and integrated. Manually adding the "Module Prefix" with a dot to clarify the definition context becomes mandatory in resolving the naming conflicts in at least one of the two sides of the conflict.
Description
When activating the refactoring, the context of the sub or function is used to determine its definition module's name (including the one within which the refactoring is occurring). And then the module's name is inserted prior to the sub or function name followed by a dot. This disambiguates the sub or function ownership.
For example...
'Code inside module "mFoo"
Dim headerNames() As String
Dim headerNamesSize As Long
headerNamesSize = size(headerNames) 'Original unrefactored code - "size" is a function in module "mArrays"
headerNamesSize = mArrays.size(headerNames) 'Following the first refactoring pass, the "size" function has the module's name, "mArrays" within which it is defined, prepended
headerNamesSize = Geocoder.mArrays.size(headerNames) 'Following the second refactoring pass, the "size" function has the project's name, "Geocoder" within which the "mArrays" module is defined, prepended
Additional context
Assuming the context of a successfully compiled state, the existing parsed state already holds EXACTLY these relationships. In fact, that is precisely the information being displayed to the right of the "Ready" button.
I don't have enough experience refactoring Excel yet to know if also providing the project name prefix with a dot in front of the module would be as useful. If so, then perhaps this refactoring could prepend a module name to a sub or function. And then if there is already a module name, prepend the project name to the already existing module name.
I also sense there is a possibility of adding some sort of inspection which identifies calls to simpler named subs and functions be prepended with its defining module to proactively avoid the naming conflicts and refactoring efforts later.