- Debugging is extremely important:
This would probably not make you write a great code but this tip is sure to make you a better programmer. If something doesn’t work in life, does it fix itself by thinking a lot about it or when you keep staring at it. None, right? The same is the problem with the codes, if you find a code you need to fix it. Not just sit and curse your destiny.
Debugging is nothing but traveling reverse through th logic of your code till you find that place which is giving you the bug and is interrupting the working. Even if you use debugger or use print_r() and echo() at all suspicious places, it wont help. Reverse tracking is very important. I’ll explain how to go about it.
o Firstly, check the current place for bug, if doesn’t give you bug you should go ahead
o Move some two to three lines behind and execute the program, if the program still doesn’t operate then that piece o f code is fine.
o Go more backward till you find a place from where the code is executed. That is the point where the error is possibly occurring.
I am not trying to be rude or bold but this is the most basic quality required in any programmer. A programmer must be capable of performing these tasks. This will help you solve the toughest of problems that you might come across
- Check your name:
A code that uses proper variable names I said to be the best of codes. In such a code you can actually keep a track of all the happening in the program. So, a good variable name needn’t follow the Hungarian notation but it should actually correspond the task or category that the variable name belongs to. Using variable names like A, B, X, Y, $Arr etc is the most foolish thing to do. Imagine a new user using your code or rather you using it 2 years down the line you trying to extend it. You’ll be in unimaginable mess.
- Avoid database queries:
This is the basic of coding. But how many of us takes care of this actually. When was the last time you sat to clearing and improving your loops. how many of you all spends time in deleting not so important stuff? DB queries occupy a lot of place on server. It should be kept the lighter possible. Here are how do we reduce the use of this:
o To avoid this, we should be using joins and left joins also, inner selects when joins and the left joins fail to work
o We should also use some temporary tables. This helps a lot in the purpose.
o Use collection when none of them work at all. Do not run one query at a time. Use of collection of queries will solve the issue of overloaded server
Bookmarks