tags:

views:

40

answers:

1

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 need to modify them.

A: 

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.

Peter Lillevold
Thanks, I thought this would be the best way, but then i saw some other code doing a similar thing that stored the data in one variable, so I wondered which was better.
Jonathan