How I fixed a bug
- I was writing a test for rename() when oldPath==newPath (You can see a discussion here). It was expected that function will successfully rename a file, but it failed. We came to the conclusion that function implementation has a bug. Bug was assigned to me and I started working on it.
- I went to the implementation file, found rename() and tried to understand how it works.
- I found out that find_node() is called and went to it.
- In find_node() another function is called, in another function one more function is called, etc. There was a long way to find a mistake, a lot of functions was called. This long process is not interesting to read about, so I will not write about all ifs and function calls.
- Finally, check_if_new_file_exists() is called. It has this "if" inside:
if(_(newDirectoryData).has(newname)) { callback(new Errors.EEXIST('newpath resolves to an existing file', newname)); } |
Fixing bugs in your own code is sometimes difficult, even though you know how your code works. But fixing bugs in someone else's code is always more difficult: you have to find out how it works. Different styling and programming techniques slow down debugging. So, I think it would be more rational if a person that wrote a code fixed bugs himself and other people just wrote tests.
No comments:
Post a Comment