I was struggling to speak. No words were coming out from my mouth. It’s 8 am, and my desktop was still on after working overnight with my brother. It was interesting to experience my vocal cords collapsing after a 24-hour work to debug a complex problem.
The challenge at that time was how to convert the existing users of our accounting software from multi-database to single database/multi-tenant model. There were about 30 company subscribers we need to migrate in a software-as-a-service (SAAS) or application service provider (ASP) model that was the term at the time around the year 2004.
What is Debugging? According to Wikipedia, Debugging is the process of finding and resolving defects or problems within a computer program that prevent correct operation of computer software or a system.
Debugging tactics can involve interactive debugging, control flow analysis, unit testing, integration testing, log file analysis, monitoring at the application or system level, memory dumps, and profiling.
To me, the most effective way to debug is bug isolation. It is a technique where you break down the big problem into small chunks or small modules, then solving it one at a time. In the problem I mentioned above, we isolated the problem by identifying which part of the program can we modify with the least effort because we were also pressured in time.
So how do you apply debugging techniques in real life? Here’s my take:
Step 1 – Simulate the bug. When the bug is reported, you have to ask the reporter how did the bug occur. What was the user input, what was the process, function or the button pressed and what was the output vs. the expected result?
In real life, you have to define the problem first clearly. A money problem, for example, may not be the real problem. The real question is the person who doesn’t make efforts to find a job or business and make money.
Step 2 – Isolate the bug. Breakdown the functions or methods line-by-line and see where the problem occurred. Was it when the button was pressed? Was it the data type the user inputted, was it when the button press signals the function to proceed or was it when the function returned the value? In coding, we put breakpoints to see exact behaviors or return values each line.
In real life, we can break down the problem as well. Going back to the money problem, we can iterate the possible causes like, am I spending more than I earn? Why am I not motivated to find a job? Is it depression? Am I an impulsive buyer? Once you have identified the cause, then it is easier to find a solution.
Step 3 – Solve and test. Solutions mostly are theories at first. In coding, you have to test your work by simulating the problem again and see if it still happening. In real life, if the cause of your money problem is being an impulsive buyer or spending much, then the solution is to devote efforts to analyze the budget and follow it. There are a lot of free apps where you can set a budget monthly, track it and forecast what happens to your cash balance if I buy this piece of equipment using my credit card and pay it in installment. That’s where testing happens.
These are just very few examples. Other real-life problems like relationships, business, health can be solved using these techniques. The most important thing is you don’t tolerate your problem when you see it.