[Tutor] globals and map()

Kent Johnson kent37 at tds.net
Tue Jul 19 14:43:54 CEST 2005

Luis N wrote:
> On 7/19/05, *Kent Johnson* <kent37 at tds.net <mailto:kent37 at tds.net>> wrote:
>     Luis N wrote:
>      > I'd appreciate some comments on my use of globals and the map
>     function.
>     I don't see the need for the global declaration; desc, vw,
>     primaryKey are all assigned within this function and returned to the
>     caller.
> In this case consider desc, vw, and primaryKey to be of the same 
> importance as dbs, other functions must access them in a way that 
> renders their being local impossible, unless the logic where to be 
> encapsulated in a class, which didn't seem necessary.

If you have several functions in one module that need access to the same variables, that is a good indication that using a class might be a better design. OTOH using a module to encapsulate the state (as globals) is OK if you only need one set of globals.

Is there something that bothers you about using globals? I'm not sure why you asked for comments.


More information about the Tutor mailing list