Environmentally Friendly Programming
Environmentally Friendly thinking can apply to Programming. We’re not talking about your programming environments here. What we are talking about is using the 3 R’s, Reduce, Reuse, and Recycle as part of your Coding Practices. These principles are taught at most schools. At least it was at mine. However, when you start off on your own with no formal education, you can run into some problems. Let’s take a look at these basic principles.
Reduce
Reducing code is fairly simple. Quite frequently used as part of defining “Beautiful Code,” using the least amount of code to accomplish the task at hand. Since that’s the case, it’s also usually the hardest to accomplish. Minimizing processing time and file loading size. You can do even some small things to reduce your coding efforts. Such as using CMS plugins already written instead of writing your own, or even modifying existing plugins to do your bidding. Here’s a very simple C example in reducing lines of code via initialization.
void foo() {
Complex c;
c = (Complex)5;
}
void foo_optimized() {
Complex c = 5;
}
Reuse
How do we reuse code? Very simply, we use functions. Instead of copying the same code in various places, functions allow us to reuse the same code again. Similarly, using a global Debug boolean to turn on/off debugging is another way to save some time. Here is a small piece of code not performing reuse.
unsigned int random_number1; unsigned int random_number2; rand_seed = rand_seed * 1103515245 +12345; random_number1 = (unsigned int)(rand_seed / 65536) % 32768;
And the same performing reuse.
int rand()
{
rand_seed = rand_seed * 1103515245 +12345;
return (unsigned int)(rand_seed / 65536) % 32768;
}
int main() {
random_number1 = rand();
random_number2 = rand();
return 0;
}
Simple and elegant. This also allows us to make changes to the function and having it take effect in all the places the function is called. Whereas, the opposite, would require us to go and make the changes in all of the places we used the same code.
Recycle
Recycling code can be fairly easy. Creating code clips/snippets that you frequently use and having them readily accessible is a great way to recycle code. Panic’s Coda helps you do this via their “Clips” tool. Another way is to create general use codes such as reset.css, typography.css, etc. A sandbox starter theme for your CMS of choice is yet another way to recycle code. Recycling can cut down on the development time you need to do things significantly.
How do you use the 3R’s in your programming practices?
Related Posts

Subscribe by
Follow me on
Environmentally Friendly Programming…
Environmentally Friendly thinking can apply to Programming. We’re not talking about your programming environments here. What we are talking about is using the 3 R’s, Reduce, Reuse, and Recycle as part of your Coding Practices….
Designer Handbags
Louis Vuitton replica handbags
Replica Handbags
Replica Rolex
Replica watches
Rolex Replica
Rolex shop
Rolex
Gucci bag
Gucci handbags
Gucci
Louis Vuitton
LV Bags
Replica Watches
Replica Rolex
steel shelving
storage rack
racking
conveyor chain
wow gold
maplestory mesos
tattoo equipment
tattoo machine
Replica Watches
Replica Watches shop
Cartier shop
Omega shop
Patek shop
Longines shop
casio shop
Patek Philippe shop
aion gold
buy aion gold
aion power leveling
wow gold sellers
buy darkfall
buy darkfall gold
darkfall online gold
psu meseta
buy psu meseta
phantasy star universe meseta