title: Creating testable code
body: <p>I have a file - in a large legacy codebase - containing methods that access databases.
  No classes are used, just a header file with the method declarations, and the source file with the implementation.</p>
  
  <p>I want to override these methods to eliminate the DB access during unit testing.<br></p>
  
  <p>I thought of the following options:<br></p>
  
  <ol>
  <li>Make file into class and override methods.<br> 
  The main minus here is that it results in alot of changes throughout the codebase.<br>
  Not ideal, though it does improve the code...</li>
  <li> Wrap the whole source file with an <code>#ifdef PRODUCTION_CODE</code> and create a new source file containing the stub and wrap it with the opposite, i.e. make the whole thing compilation dependent. Problem here is that in a build system that performs regression tests I would have to compile twice, once in order to create the apps and do regression tests, and an additional time to create the unit test executables.</ol>
  
  <p>Any recommended ways of doing this?</p>