Actually I had drafted below notes, several years back but somehow I forgot to post it here. So here you go..
In this post I would like to talk about some of the do’s and don’t if you are into computer programming
- never write a sql query inside a loop, most of the times there is better way to achieve same
- sometimes it is efficient to do computation at sql level rather than programming logic
- But huge sql is not aways a best solution, so splitting into multiple queries might yield better results
- instead of * using field list
- instead of array count use count(*)
- optimizing sql queries – there is always room for optimization
- always use versioning system, even if it’s only you who is working on the project
- writing an efficient “if” loop, most common use case should be in “if” condition
- do not comment non-usable code, this aggregates unnecessary code and adds to confusion, so better to delete
- understand the logic before implementing/writing the code. I feel it’s a good practice to write the complex functionality in simple english first and then build logic around it
- follow one coding standards – so that others and you can understand your code better in future. Choose one naming conventions for modules / functions – follow same conventions through out the project
- commenting code as much as possible to explain the functionality – not many have photographic memory so this helps
- if possible always use a issue tracker, it help you to understand the state of the project
- copy+paste is good in moderation, so use it wisely 🙂