Original Post
Here's a little story for you regarding a small project my boss is having me do. I am using ColdFusion (a language type mixing HTML and variables and such, like PHP in Macromedia). So I need to create a main record in a table, then create multiple records in another table under that record that would each, in turn be the total items on a customer order. That main record would be a total type record of all the smaller records under it which would each be a total of items in a customer order. Obviously my first thought would be a main loop creating the header item with a sub-loop going through each order and totaling and making a smaller record, coming out of that loop to update the header record, and then loop to the next set of header record and sub-records. Instead, to make the code 'easier to read and maintain' my boss, who isn't very much of a programmer (more of the business guy) told me to do this instead: Run a loop and create an array containing each of the ID's I'll be using for the header record which makes some sense. Then I create another loop and check the array item I'm in against the order vendor ID and using a series of nested IF's within the loop, add and update the sub record; if the record I'm checking is a different item in the array I index my array to the next value. Confusing? It gets worse. After this next loop (assumingly, he hadn't figured out this portion yet) I'm going to need to run through each array item and update that header record with a number that's currently stored in a single variable (but obviously will need to be stored in an array in this model). Must...not..scream...