Many people think that, fixing bugs is inferior work, and many people try to avoid it.
Many people forget that, the quality or greatness of the work is not in the work itself, but, how the people make out of it.
Recently, I got an interesting bug. The bug is very simple. It is a Null Pointer Exception. If that bug is given to any fresher, who has little programming knowledge, they can fix it in five minutes, and it will pass the testcase. But, I took lot more time.
When I had written the code, I assumed that, it won't return null, and coded accordingly. Now, when I got null, I checked why it is returning null. I found that, the corresponding Dictionary has not been populated. It was not populated, because, DB was not returning it. When I checked, what DB is returning, I found that, when the input has 600 ids, DB is returning only for 200 entities. The issue is, the stored procedure's input parameter can hold only 200 ids. Increasing the size of the input fixed this issue.
But, this is not the final solution. The null exception is coming even for basic scenarios. In basic scenarios, it should not be processing hundreds of entities. When I checked, why it is processing that many entities, I realized that, at one place, where it has to update it's dependents, it is updating all the entities in that component. When I am creating a new entity, it won't have any dependents. But, since, it is taking all the entities in the component, it is trying to update all the entities in the system.
My final fixes were, changing the code to update only it's dependents, and increasing the size in the stored procedure. I did NOT add null check in my code. If I get null again, it means, there is some big issue somewhere else.
If I had just added null check in my code, it is very difficult to find the issue, because, this entity would be updated properly. This failed in an asynchronous job. So, it is very rare that, as part of this testcase, tester tests other entities which are not involved with this entity. While executing the testcase for dependents, if the component does not have 200 entities, then that also would pass.
There is no work that can be done by the less qualified people. It is just that, we do it like the way less qualified people.
By the way, since, that Null Reference exception came in my code, I did more investigation. If it had been in other's code, even I would have finished it in five minutes. ;)
On a different note, my lead told me to put the effort spent for bug fixes in hours and not in minutes. I don't know how he felt, when I said, I am putting effort in hours only.
Thursday, May 24, 2012
I Don't Want to Work on Bug Fixes
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment