Store data in one variable or multiple?
I have a file which is opened and the bytes are loaded into a class.
The file needs to be split into chunks, and there is a header which gives the locations and sizes of the chunks. Should I (upon opening the file) split the file into chunk sand store each chunk in an array of variables And then when I want to access the data in the chunks I just use the array.or store all the chunks in one variable together and then when I need access to the chunks get the location and size of them and use that to find chunks each time I ne开发者_StackOverflowed to modify them.
In general I would say that in a class you should arrange your properties (and methods too) so they are easy to use in code that will be using this class.
So when loading these chunks from file it seems natural to do the splitting once so you won't have to repeat the process, and place the data in easy-to use data structures.
精彩评论