You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ponymail.apache.org by sebb <se...@gmail.com> on 2021/11/20 19:47:09 UTC

ponymail.js has too many global variables

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.

Sebb

Re: ponymail.js has too many global variables

Posted by sebb <se...@gmail.com>.
On Sun, 21 Nov 2021 at 22:53, Daniel Gruno <hu...@apache.org> wrote:
>
> On 21/11/2021 23.50, sebb wrote:
> > On Sun, 21 Nov 2021 at 22:43, Daniel Gruno <hu...@apache.org> 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
> >>>
> >>
>

Re: ponymail.js has too many global variables

Posted by Daniel Gruno <hu...@apache.org>.
On 21/11/2021 23.50, sebb wrote:
> On Sun, 21 Nov 2021 at 22:43, Daniel Gruno <hu...@apache.org> 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.

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


Re: ponymail.js has too many global variables

Posted by sebb <se...@gmail.com>.
On Sun, 21 Nov 2021 at 22:43, Daniel Gruno <hu...@apache.org> 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.

> >
> > Sebb
> >
>

Re: ponymail.js has too many global variables

Posted by Daniel Gruno <hu...@apache.org>.
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.

> 
> Sebb
>