Tuesday, April 29, 2014

Applying the 4 R's of conservation to Software Development

Refuse, Reduce, Reuse and Recycle. It works to reduce landfill, It also works to ensure our code and documentation does not end up in the virtual landfill and it is properly used by future generations

Here is how I relate it to code in particular, and as you will see, applying one makes it easier to apply the others. (Note, this is a short post as I am on vacations :) )

Refuse
Do not write code you don't need to write. This applies at different levels, here are some examples
- Avoid automating one-off tasks
- Before automating a process, ensure it has been properly re-engineered. A bad process automated is still a bad process
- Don't write code already exists just because you don't understand it or like it

Reduce
When it comes to code, less is more. Less to maintain, less opportunities for bugs to creep in, easier to extend.
- Don't write code you "may" need. Write it as you need it. There are many techniques to allow extending the functionality as needed.

Reuse
Reuse existing code. The likelihood you are the first person facing a problem is fairly low.
- Search around for existing code, either in the form of libraries, frameworks, the internet and your own code.

Recycle
Code for Reuse: Follow techniques that allow others to reuse your code.
- Write libraries, frameworks, code with dependency injection in mind, Expose extensible interfaces, etc.

In future posts I'll review practices that directly relate to these 5 R's.

This week I will close my computer and continue my vacations. I think I will write my next post on my way back from Mexico.

No comments:

Post a Comment