Seriously take a stab at breaking that one very long method into several that each do bits of work
Long term it will make you code easier to maintain and you’re much less likely to run into surprises like this
[quote=122906:@Norman Palardy]Seriously take a stab at breaking that one very long method into several that each do bits of work
Long term it will make you code easier to maintain and you’re much less likely to run into surprises like this[/quote]
To start with, would it not be cleaner to do the concatenation thing in a separate method ? That way temporary variables would be cleaned upon return, right ?
[quote=122911:@Norman Palardy]I’ve seen this code once before attached to a bug report
It could be refactored into several smaller chunks and this problem would not exist[/quote]
No Norman, you did not see this method before. The one you saw could (and is now) be splitter into smaller pieces.
Here is a snipped of the code of a method that write some presets to a file.
There are about 700 preset options. So in total about 1400 lines of code.
It would not make sense to split this method. It would only make it harder to read.
[code] dim line as string
line = line + “EncodePreset “+batchlist(batchID).EncodePreset+””+chr(13)
line = line + " "+chr(13)
line = line + “EncodePresetName “+batchlist(batchID).EncodePresetName+””+chr(13)
line = line + " "+chr(13)
line = line + “EncodePresetMenuCheckedNumber “+str(batchlist(batchID).EncodePresetMenuCheckedNumber)+””+chr(13)
line = line + " "+chr(13)
line = line + “EncodePresetSubCheckedNumber1 “+str(batchlist(batchID).EncodePresetSubCheckedNumber1)+””+chr(13)
line = line + " "+chr(13)
line = line + “EncodePresetSubCheckedNumber2 “+str(batchlist(batchID).EncodePresetSubCheckedNumber2)+””+chr(13)
line = line + " "+chr(13)
line = line + “EncodePresetSubCheckedNumber3 “+str(batchlist(batchID).EncodePresetSubCheckedNumber3)+””+chr(13)
line = line + " "+chr(13)
… CUT some same text as above
line = line + “EncodePresetSubCheckedNumber3 “+str(batchlist(batchID).EncodePresetSubCheckedNumber3)+””+chr(13)
line = line + " "+chr(13)
dim fs as folderitem
dim ts as textOutputStream
fs = SpecialFolder.ApplicationData.child(“presetsFolder”).child(presetfile)
if fs <> nil then
ts = TextOutputStream.create(fs)
ts.writeLine(line)
ts.close
end if
[quote=122939:@Christoph De Vocht]No Norman, you did not see this method before. The one you saw could (and is now) be splitter into smaller pieces.
[/quote]
I assumed this was all part of that same gigantic method
I’d still split this into smaller chunks