开发者

Store data in one variable or multiple?

开发者 https://www.devze.com 2022-12-18 08:54 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消