Monday, March 30, 2015

My favorite Bugs

Every Software Developer comes across bugs, its just a fact of life. Sometimes they are in the code, sometimes they are actual live bugs inside your computer. Im looking at you, people who eat on top of their computers, especially the ones who eat chips. But right now were going to talk about our favorite bugs, more specifically my favorite bug. Every programmer has a favorite bug, its the one that you do not understand no matter how much you investigate, and theres no answers on stackoverflow. Over the course of the past month I have dealt with many mundane bugs, that are easy enough to solve and fix. Normally they are problems I have created myself due to typos and normal beginner programmer mistakes, but my all time favorite is my wonderful called "Magical Delete Bug", and the best part is he's still on the lose. Although I dont actually believe in this meme, I still find it hilarious because thats basically how I described the bug to my teammate, a "special feature".


So the original problem for me to solve was our web-socket needed to delete the users location when they logged out. A relatively simple JQuery click-event that is attached to our log out button, so I had the logout button assigned an id of logout, and called the click event in my swampdragon code.


The funny thing is this code likes to work randomly, for the first week it would work on my teammates computer but would not work on mine. Eventually I had other work to do and this problem was not pressing, annoying, but not my biggest problem. But eventually I pulled from my partners code and the delete button started working, the funny thing? The code on the appropriate pages never changed, they were identical, I went through their history with my pycharm. It was all very suspicious, I assumed it was something to with the way the pages were being loaded. 

But then it got interesting, really interesting. For the sake of our presentation I needed us to stop deleting the users locations, so I commented out my code in the swampdragon ready function. And the code continued to function, as if it was never commented out. Now this was really annoying and for the sake of the presentation I just worked around it. But I already know that in coding things might not make sense as to why they are working/happening, but there is no magic. I already know that the reason the function was still working is because I did not restart the code, or at least its a good guess, and probably the closest I will get to the truth. Because now that I have returned to the code a few days later it has decided to stop working again. 


A lot of developers would probably think its silly to find a bug amusing, but theres something special about knowing a problem exist and getting to enjoy the cat and mouse chase of solving it without any real path to the solution. Theres no Django yellow error page, or the cryptic angular errors, its just me and my broken bipolar code. 


Id like to leave this post with an appropriate ending that I think currently describes how I feel about testing code.


 This is basically our entire projects testing in a nut shell. I am actually looking forward to writing some good old test cases for our project, making my life easier. I might not be completely sold on TDD, but I can agree that tests do make my life easier, even if currently write them after I write the code. But I will eventually flip the tables. 

No comments:

Post a Comment