[Javascript] code review

shawn_milochik at godivachoc.com shawn_milochik at godivachoc.com
Wed Aug 4 09:07:46 CDT 2004





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.

**********************************************************************




More information about the Javascript mailing list