The ratio of time spent reading code vs writing code is over 10 to 1. Programmers spend most of their time looking for a file, looking for a function etc. So when you spend your time writing a clean code, it is an investment in the total amount of time you need for your project.
We like to think we spend our time power typing, but we actually spend most of our time staring into the abyss * Douglas Crockford
So without further explanation here are 10 Quick tips for making our code clean.
1. You are responsible for the quality of your code
Every profession has professional standards and we have to be advocates of quality standard in our field.
2. Use meaningful names.
Don't name variables like $d, instead specify it as $elapsedtimein_days or $daysSinceCreation.
3. Write code that expresses an intent
Method name just like the variable name, so even if you lost context, you know what is going on.
4. Comments are lies waiting to happen
A code should speak for itself whenever possible. So, it's not like never write comments but you don't have to depend on them.
5. Leave your code better than you found it.
A code, usually, gets messier and messier with many hands and time upon it. To make the opposite happen, you should always work to leave the source code in a better situation than you found it.
6. The single responsibility principle.
A function or method does one thing only and it does it well. If you are passing a large number of variable to a function, it probably is doing a lot of things.
7. Write tests.
An integration test, which tests the experience of the user and unit tests, which tests a functionality in an isolation.
8. Work in short cycles: incremental and iterative.
Short cycles of incremental or iterative development lower the risks of development.
9. Independent architecture.
Software architecture are structures that support the use case of the system...
Frameworks are tools to be used, not architectures to be confirmed to" * Bod Martin
10. practice, Practice, Practice.
Musicians don't just play on a studio, or a stage. Always be coding even though there is no client paying you.