Categories
General

Debugging Unfamiliar Code

Yesterday I had the opportunity to debug a problem with our document builder. It was my first time debugging this project. I had no idea where the issue was or where to start looking. In this case, I asked for help and Robert point me in the right direction.

First Hour

Frustration. It is human nature to be frustrated when you don’t know how something works. Remember the last time you were lost in a new city. Or the time when you assembled furniture but you end up with too many parts. After looking at the code, it did not make any sense to me. It was a lot of code to digest and find the problem. I searched for the work “GOLD VENDORS” in our codebase and nothing was returned. At this point, I know for sure the issue is coming up from a database table.

Second Hour

After my first hour of frustration, I knew that the issue had to be coming from the database. But which database Sybase or SQL Server? The only way to know is to actually read the code and step into it until you find it. My friend Robert gave me the project name responsible for building this document so that narrowed my search and focus. The issue is somewhere in the middle of the document. Header, table of contents, and footer look correct. I commented out different sections to see where the issue was. Still no luck. I know that I’m very close. I just need to continue. I can see the light at the end of the tunnel.

I continued to comment out code until I see the section and the problem. Now I know the C# method responsible for this bug.

Third Hour

Excitement. I’m excited at this point. I know the method causing this issue and now it’s a matter of fix it. I spent the next hour inspecting variables and see a lot HTML with the word “GOLD VENDORS” in it. I found the smoking bug. I have evidence and can take this code to trial. I kept digging into the codebase and found the table named “document_maintenance”. I’m 100% sure that the issue is coming from the database and also know the table name.

I asked Robert, “Do you know a table name document maintenance?.” He replies, “yes, that’s where we keep document templates”. We opened the document and find the word “GOLD VENDORS”. Finally.

My friends gives me a brief history of the document templates and we close this bug. User error not a bug.

Conclusion

I’m glad I had the opportunity to work on this ticket. It gave me a chance to work on a new project. I went from being frustrated to being excited. It also gave us an opportunity to transfer knowledge. Happy debugging!