title: Optimization and testability at the same time - how to break up code into smaller units
body: <p>I am trying to break up a long "main" program in order to be able to modify it, and also perhaps to unit-test it. It uses some huge data, so I hesitate:</p>
  
  <p>What is best: to have function calls, with possibly extremely large (memory-wise) data being passed, </p>
  
  <p>(a) by value, or </p>
  
  <p>(b) by reference</p>
  
  <p>(by extremely large, I mean maps and vectors of vectors of some structures and small classes... even images... that can be really large)</p>
  
  <p>(c) Or to have private data that all the functions can access ? That may also mean that main_processing() or something could have a vector of all of them, while some functions will only have an item... With the advantage of functions being testable.</p>
  
  <p>My question though has to do with optimization, while I am trying to break this monster into baby monsters, I also do not want to run out of memory. </p>
  
  <p>It is not very clear to me how many copies of data I am going to have, if I create local variables.</p>
  
  <p>Could someone please explain ? </p>
  
  <p>Edit: this is not a generic "how to break down a very large program into classes". This program is part of a large solution, that is already broken down into small entities.</p>
  
  <p>The executable I am looking at, while fairly large, is a single entity, with non-divisible data. So the data will either be all created as member variable in a single class, which I have already created, or it will (all of it) be passed around as argument around functions.</p>
  
  <p>Which is better ?</p>