Hello All,

The use of global scope code should be minimized in order to prevent confusion 
and thereby make code more understandable and maintainable.  After some 
analysis of emerge's global scope code, I am confident that all of it can be 
refactored quite easily, with no regressions or changes in functionality 
(reorganization only).

In order to accomplish this goal, I have categorized the global scope variables 
by which parts of code depend on them.  The variables are listed in the 
following table, in the order that they occur in the source code:

Variable Name        Dependency
-------------------------------------------------------
spinner              search.execute(),depgraph.create()
merged               unused
params               unused
actions              local
options              local
shortmapping         local
myaction             global
myopts               global
myfiles              global
edebug               global
verbosity            global
tmpcmdline           local
cmdline              local
CLEAN_DELAY          unmerge()
EMERGE_WARNING_DELAY global
myparams             depgraph.create(),depgraph.xcreate()
add                  local
sub                  local

Variables within a given category can be dealt with in a similar manner.  For example, variables 
with "local" dependency should be enclosed within a function or method along with the 
code that depends on them.  Variables with "global" dependency can either remain as 
global variables or become instance variables of an object.

Based on this analysis, I believe that I can quickly create an emerge 
refactorization patch for portage-2.1 with no regressions or changes in 
functionality (reorganization only).  If all (or some) of the portage 
developers agree that it is a good idea then I would be happy to create a patch 
for all to scrutinize. :-)

Zac
--
[email protected] mailing list

Reply via email to