Video Version can be found here.
Bugs or Programming problems are part and parcel of the life of every programmer. Today, I am gonna discuss some of the bug handling techniques which are learnt over the last few years while programming
Here are a few rules to handle the bugs effectively.
1 - Always have a Plan - I learnt that rule from a book Think Like a programmer. The author says in the first chapter, You should definitely have a plan before solving a programming problem. When you are developing a new algorithm, start planning about it, Even a little plan is enough, after all, plans are made to be replanned. But a plan gives you a direction to follow.
So when you are trying to find the solution a programming problem, plan and point out what are the areas of the program where there may be the problem. Start testing each step and make sure each step is working correctly. As someone said, the well-defined problem is half solved. same way, if you know where the problem really is, you can come up with the solution quickly.
2 - Use Pen and Pencil to Plan - From my personal experience, when I try to do the planning with pen and paper, I come up with the ideas faster.
3 - Always look for the reason - Most often than not, we usually don't know where the problem is coming from. Trying to test each step and make sure the output from each step is as expected will help you get to the root cause of the problem quickly.
4 - Use some Debugging Tool like Xdebug - I procrastinated a lot on using Xdebug. I thought I don't need that, I have var_dump() or printer. but believe me, sir, You need a debugging tool, It will take a little bit of effort to set up at first, but it's definitely worth it.
boolean $decision = false; // typecasting the $decision variable to boolean $decision = 'string'; // will produce error
6 - Finally, Use interfaces - interfaces are your friends, They gonna help you in IDE code completion, Prevent many potential problems and make your code more readable.
That's all from my experience. Should you have any other idea or have a question, please do share in the comments box. Thanks