Just your Opinion

So, I have a Game where I have to store TEN THOUSANDS (and hopefully a lot more) of 0/1; think of a Minesweeper game where every cell has a 0/1 value and they dinamically change every X seconds.

Obviously a great difference is in HOW you code it but just for the sake of theory, to have better performance, do you think it’s better to:

  • use a variable for every value;
  • use a structure or array that contains all the values;
  • use a single string variable where I put every value;
  • other ideas or advice?

P.S.: there is a MAX for the length of a single String or the number of indexes in an Array?

Using the Minesweeper example; say the cells are predominantly 0, then I’d look at only storing the exceptions in an array. To change it, you’d just have to clear the array and repopulate.

1 Like