On Sun, 21 Nov 2021 at 22:53, Daniel Gruno <[email protected]> wrote:
>
> On 21/11/2021 23.50, sebb wrote:
> > On Sun, 21 Nov 2021 at 22:43, Daniel Gruno <[email protected]> wrote:
> >>
> >> On 20/11/2021 20.47, sebb wrote:
> >>> There are a lot of global variables in ponymail.js.
> >>>
> >>> It ought to be possible to limit the scope of these somehow to just
> >>> the functions that need them.
> >>>
> >>> Suggestions welcome.
> >>
> >> Some variables should be combined methinks, such as the display options
> >> and cached json documents. I'll see what I can do about that.
> >
> > Whilst that helps, the variables are still open to accidental corruption.
> >
> > I was hoping there might be a way to limit variable scope.
>
> Yeah, that needs to happen to some extent as well, that variables get
> passed along more, but there are a lot that are merely kept global for
> caching/offline purposes or for where session/local storage has been
> disabled. I think realistically we can "get rid of" probably half the
> globals.

You could get rid of all bar a single object if that held all the others.
But that is not really a solution, as it still binds all the code
sections together.

Ideally where several functions need to share variables, these should
be limited in scope to just those functions.

Does Javascript not offer some kind of class variables?

> >
> >>>
> >>> Sebb
> >>>
> >>
>

Reply via email to