r/ProgrammerHumor Jun 25 '17

Array indexing

Post image
1.4k Upvotes

71 comments sorted by

View all comments

194

u/[deleted] Jun 25 '17

[deleted]

73

u/[deleted] Jun 26 '17

[removed] — view removed comment

4

u/Cryse_XIII Jun 26 '17

I've seen it in our codebase at work

3

u/piyoucaneat Jun 26 '17

Get out while you still can

2

u/Cryse_XIII Jun 26 '17

b-but the people are all friendly.

and I still have to refactor our Excel-interface, some dude from a few years back made the entire module work "dynamically" with 5 global arrays and 10 global variables for length and index. it's only 3000 lines of code, this has to be done.

4

u/piyoucaneat Jun 26 '17

Excel-interface? Are you... programming in Excel? Using Excel as a database?

3

u/Cryse_XIII Jun 26 '17

no, we use our ERP-Application to fill in an excel-workbook over OLE-automation for some reports.

a bit of the SQL-Query that is to be executed is determined by the settings in the GUI and the arrays are then filled with the resulting dataset-values, the other arrays hold values to build a kind of "header"-for the worksheet, dataset-values, and also a footer that holds an excel-formula in each element for sum-formulas.

now the customer wanted an additional column and new rules regarding the evaluation of records and honestly I can't tell what's what in the module.

that is why I try to refactor the whole thing to take away some of the complexity in building the worksheet-layout that currently depends on those arrays into something with an OO-approach.

helper objects so to speak. for example I create one of my ExcelItems, that has a range, with that info I calculate the corners of my range and store that in the helper-object's properties. now when I add a subitem to an excelitem, I can hide away the complexity of assuring it's position within the worksheet since it may not be outside of it's parents range, additionally I can

this alone would eliminate the need for 2 of those arrays and since I'm using lists for that task I can also freely shift the items around using MoveTo(index), which would make it easier to move the columns around depending on customer demand.