Because I had a lot of issues lately with free and commercial extension I've decided to ask this question and answer it with the steps I usually follow when writing an extension. Feel free to edit the answer or add a new one.  
In most of the cases when installing an extension or a theme I have to spend a few hours (sometimes more, sometimes less) to make it work on all the environments I need:

 - dev: usually `localhost` where the project is in a subfolder
 - preprod & live

This has happened even with extensions from large extension providers (that should remain nameless at least until I get really really mad and add their names in here)  
**So the main question is..what steps should I consider when writing an extension to ensure the quality of the code and and make it easier for a technical and non-technical person to use it and for a technical person to change it?**