I have a function that consists mainly of a massive amount of calls (50+) to another function which inserts data into an array, with logic here and there dictating various conditions to insert various items into the array (plus a little bit on the end that writes the contents of the array out to a file). I'm wondering if there isn't a better way to make this function; I suppose i could start with logically splitting array insertion command sets into their own functions, but I'm wondering if there's any more I can do. Is there?
Example:
function buildTable(fileName, data)
local dataToWrite = {}
table.insert(datTWrite, {
Type = "type1",
Key = "someKey",
Value = data.SomethingInteresting
})
--and so on ad nauseum with an occasional but of actual logic to spice things up
dataWriter:open(fileName .. ".bla")
dataWriter:batchWrite(dataToWrite)
dataWriter:close()
end
In this case, dataWriter is an instance of a predefined class that handles the process of writing to a file.