[Javascript] code review

Matt Barton javascript at mattbarton.org
Wed Aug 4 09:32:39 CDT 2004


Another trivial[*] comment I'd make is that, personally, I hate variable
names like "itm200" and "loItm200" and find code much more readble (and
hence, understandable) when using more descriptive names.  Particularly in
situations like this where you've got lots of variable names together in
tight loops, and very similar looking varaible names.

Just my £0.02p

Matt
-----

[*] One man's trivia, being another mans detail... I'd not call this
instance trivial, but I'm aware that others, rightfully, would consider it
to be so.  Far be it from me to say that my coding standards preference is
"correct".  Many ways to skin a cat etc, etc.


----- Original Message ----- 
From: <shawn_milochik at godivachoc.com>
To: <javascript at LaTech.edu>
Sent: Wednesday, August 04, 2004 3:07 PM
Subject: Re: [Javascript] code review


> This may seem trivial, but I always set my tabs to three spaces.  It looks
> like you're using 10 or 12, which
> is making this much wider than it needs to be.
>
>
> Here is how I would format this.  Still a big block, and depending upon
> what font you are viewing this in, the
> spacing may be weird.  But with a fixed-width font, I think that this is
> reasonable.
>
> for (var itm200 in loMainItem.Item0200) {
>    var loItm200 = loMainItem.Item0200[itm200]
>    for (var itm100 in loItm200.Item0100) {
>       var loItm100 = loItm200.Item0100[itm100]
>       for (a100 in loItm100.Area0100) {
>          var loA100 = loItm100.Area0100[a100]
>          if (loA100.Customize==1) {
>             for (a110 in loA100.Area0110) {
>             var loA110 = loA100.Area0110[a110]
>             if (loA110.Type==2) {
>                if (loA110.Customize==1) {lnRtnVal+=1}
>                } /* if (loA110.Type==2) */
>             } /* for (a110 in loA100.Area0110) */
>          } /* if (loA100.Customize==1) */
>       } /* for (a100 in loItm100.Area0100) */
>    } /* for (itm100 in loItm200.Item0100) */
> } /* for (itm200 in loMainItem.Item0200) */
>
>
>
>
> Shawn
>
>
>
>
>
>              mdougherty at pbp.co
>              m
>              Sent by:                                                   To
>              javascript-bounce         javascript at LaTech.edu
>              s at LaTech.edu                                               cc
>
>                                                                    Subject
>              08/04/2004 09:23          [Javascript] code review
>              AM
>
>
>              Please respond to
>              javascript at LaTech
>                    .edu
>
>
>
>
>
>
> Given the rather long object tree below, was there a better way to
> structure the data/objects so
> this kind of code could have been avoided?  (there are few objects in each
> collection, and it
> processes very quickly even on slow machines, but it's not pleasant to
> read)
>
>
> for (var itm200 in loMainItem.Item0200) {
>              var loItm200 = loMainItem.Item0200[itm200]
>              for (var itm100 in loItm200.Item0100) {
>                          var loItm100 = loItm200.Item0100[itm100]
>                          for (a100 in loItm100.Area0100) {
>                                      var loA100 = loItm100.Area0100[a100]
>                                      if (loA100.Customize==1) {
>                                                  for (a110 in
> loA100.Area0110) {
>                                                              var loA110 =
> loA100.Area0110[a110]
>                                                              if
> (loA110.Type==2) {
>
if
> (loA110.Customize==1) {lnRtnVal+=1}
>                                                                          }
> /* if (loA110.Type==2) */
>                                                              } /* for
(a110
> in loA100.Area0110) */
>                                                  } /* if
> (loA100.Customize==1) */
>                                      } /* for (a100 in loItm100.Area0100)
> */
>                          } /* for (itm100 in loItm200.Item0100) */
>              } /* for (itm200 in loMainItem.Item0200) */
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
>
>
> **********************************************************************
> This e-mail and any files transmitted with it may contain
> confidential information and is intended solely for use by
> the individual to whom it is addressed.  If you received
> this e-mail in error, please notify the sender, do not
> disclose its contents to others and delete it from your
> system.
>
> **********************************************************************
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
> -- 
> This email has been verified as Virus free
> Virus Protection and more available at http://www.plus.net




More information about the Javascript mailing list