Conditional compilation is one method you can use to save program space without removing code. It allows you to turn features on and off as needed.
An example can be found in one of the DHT22 sensor libraries
to disable the code that returns float values. At line 35, 57, and 65 you can see "#if !defined(DHT22_NO_FLOAT)". By default DHT22_NO_FLOAT is not defined so the code is included. You can define it in your code, before including the library, to disable these functions if you do not need them and reduce the compiled size slightly like:
You can also use #defines in your code to switch out debugging and production code, such as:
//uncomment this for dev mode
//#define DEVMODE 1
// Setup the LCD
i2cbuffer = "";
i2cOutput = "";
In this case, I don't initialize the LCD, and later in the code I also don't use LCD drawing functions. This allows me to test the i2c methods while watching the serial port, but sacrifices the LCD display.