This follows up a recent discussion of organizer nodes. Kent made the remark that they might encourage overly-large classes (or modules).
For several years I have considered breaking leoGlobals.py into several classes, say g.scan, g.path, g.ws, etc. Ironically, Kent's remark has had the effect of making me more comfortable with organizer nodes, and more comfortable with having lots of top-level symbols defined in leoGlobals.py. Imo, functions and classes are candidates for inclusion in leoGlobals.py if and only if: 1. They are (or could be) useful in scripts or in Leo's core. Functions that are likely to be used only once in Leo's core should be defined at the point of use. 2. They are stateless: they depend on no ivars or other state vars. 3. They depend on no internal details of any class. For example, few methods of the Position or VNode classes should ever be made functions in leoGlobals.py. Given these guidelines, I propose that we convert p.get_UNL, vc.find_absolute_unl_node and vc.find_position_for_relative_unl. These would join g.recursiveUNLSearch and recursiveUNLFind in a new organizer node called UNL's. Note that p.get_UNL uses none of the internal details of the Position class: it calls only p.self_and_parents(). There are real benefits to these moves: 1. All these functions will be available to all code and scripts via g. 2. All important unl-related code can be found in one place. 3. No pointless wrapper classes will be needed. 4. These functions will remain where they are whatever happens to leoViews.py or any other code. Many of these advantages apply to the other functions in leoGlobals.py. Furthermore, reorganizing these functions using organizer node is the lightest-weight thing that could possibly work. Such reorgs can have *no* effect on the code that uses the functions. For all these reasons, I plan to leave the functions in leoGlobals.py just as they are, except for reorgs. Imo, we could easily live with thousands of functions in leoGlobals.py, instead of the 403 functions (and several classes) that exist now. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
