Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #33681

Re: Reference var in (function(){})()

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Reference var in (function(){})()
Date 2017-08-02 11:38 +0200
Organization PointedEars Software (PES)
Message-ID <3175537.R56niFO833@PointedEars.de> (permalink)
References <KZ-dnfr95s94f-LEnZ2dnUU7-bnNnZ2d@westnet.com.au> <3122783.iIbC2pHGDl@PointedEars.de> <G_2dnUe_rNVM0hzEnZ2dnUU7-YfNnZ2d@westnet.com.au>

Show all headers | View raw


Andrew Poulos wrote:

> On 1/08/2017 8:40 PM, Thomas 'PointedEars' Lahn wrote:
>> Andrew Poulos wrote:
>>> There's some code that looks like
>>>
>>> var con = (function() {
>>>     var opt0 = {},
>>>         opt1 = {},
>>>         opt2 = {},
>>>         opt3 = {},
>>>         ...
>> 
>> Who is doing such nonsense?
> 
> It happens gradually. First, there's just one opt(ion). A few weeks
> later the designer changes the design and so pt1 gets added. And so on...
> 
> A theorist told me years ago to always build things with the
> understanding that the number of items a design requires can change.
> Some of the people I work follow instructions explicitly and if it says
> "there's one item" then they build accordingly.

As a rule of thumb, I start using arrays when there is more then one item of 
a kind.

> Ok, I did as you and Evertjan suggested and the change was easy and any
> increase in the number of opts will now be painless.

See also my supplementary posting.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Reference var in (function(){})() Andrew Poulos <ap_prog@hotmail.com> - 2017-08-01 12:09 +1000
  Re: Reference var in (function(){})() "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-08-01 09:39 +0200
  Re: Reference var in (function(){})() Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-01 12:40 +0200
    Re: Reference var in (function(){})() Andrew Poulos <ap_prog@hotmail.com> - 2017-08-02 14:06 +1000
      Re: Reference var in (function(){})() Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-02 11:38 +0200
    Re: Reference var in (function(){})() Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-02 11:33 +0200

csiph-web