"BUGS GO AWAY!!"  

My debugging adventure.

Photo by Julien L on Unsplash

"BUGS GO AWAY!!" My debugging adventure.

Hey there! I'm Gold and this article is all about my adventures in debugging: "BUGS GO AWAY!!"

"BUGS GO AWAY!" is a familiar cry for developers everywhere.

As we code, encountering errors, or "bugs", can be frustrating and time-consuming and as developers, one of the greatest superpowers we can ever possess is the ability to find "bugs" and "debug" them. Okay! fancy words... I know! So, how about I break down, "bugs" and "debug"?

Picture this:

You woke up feeling very energetic and happy with yourself and decided to start your day off with coding. Beautiful right? Well, you opened your sweetheart,(lol I mean your laptop), you happily wrote lines of code, clicked the run button, and patiently waited for your code to execute. But... guess what your code decides to tell and show you it's the man by displaying an error message!

Now... that's a crazy and annoying way to start your day right?? Well, I agree! The errors that were encountered to make you feel slightly irritated are known as "bugs". And yes... they are I promise you, just as annoying to get rid of as the actual bugs that bite!

Okay... So you get irritated at the bugs showing up and decide to show the bugs who the real boss is by trying to find the cause of the error message.

You furiously stare at your screen, searching and scanning your code, trying to find that one line....or. Anyline. ...! In fact at this point... you don't even care what you do to get rid of the bug, all you want to see is your code running!

The process of finding those bugs is known as debugging.

Great! you now understand what I mean when I say "bugs" or "debug".

Well, I was in this guy's shoes a few days ago...

Positivity flowing through my veins...

Positivity was flowing through my veins as I woke up feeling good about my journey into Python and the progress I had made in a week.

I felt pretty good as I reflected on what I had learned in one week. I was glad about how fast I had picked up on the syntax of the Python programming language.

So, I thought to myself, "Since I am feeling so positive, why don't I make something out of this positivity?"

I brought out my laptop, opened Replit (an online code editor), and got to work.

I decided to create a positivity generator for each day of the week depending on if the user was a coder or not. I wanted to make sure that each of my users would have a specific response made just for them. (sighs...) that's when it all began...

Writing out my codes

So there I was writing out my codes with so much joy and excitement, feeling like if there were going to be errors it wouldn't frustrate me so much. What I didn't know was that the errors were going to frustrate me.

Writing such a program meant that I needed to have conditions which meant I had to be familiar with conditionals(which at the time I thought I was super familiar with).

Error message!

After writing my long lines of code, I clicked run, expecting to see an error message I could solve in seconds. I met a surprise.
The error message read, "IndentationError: expected an indented block", which I fixed.

I ran the code again, this time expecting it to run without errors. I met another surprise. I got the same indentation error but this time on another line. This went on for another 30 minutes. At this point, the error code had already spoilt the perfect morning I had started with, but I was pretty determined to make the code work and create the positivity generator.

Debugging my errors the right way: the developer way!

With a determined expression on my face, I sat, took a deep breath to let go of the frustrations that had built up, and went back to the beginning of my code to read my code line by line, word by word, like plain English, while explaining each line to myself. After doing this I found the cause of all of my indentation errors. It was caused by a main conditional. I used a wrong indentation, meaning that it was going to cause problems for my code no matter what I did to the other conditionals nested into it. I mentally scolded myself in the head for overlooking such an error and wasting so much time, when I could have since easily corrected it.

I got to work and quickly corrected the indentation error. I ran the code again, and this time ..... guess what? It ran!!

My joy knew no bounds as I tested the program and watched it work according to the way I had imagined it to work. With a huge, wide, smile on my face, I shared the program on my Twitter, feeling good about finally finding the error.

lessons I learnt from debugging...

The lessons I learnt from debugging the error were invaluable...

  • I noticed I was only able to solve the problem with a more systematic and organised approach and not the gorilla approach... meaning that I would use such an approach when debugging future errors.

  • Debugging helped me understand the concept of conditionals even more, meaning that, whenever I see a bug I shouldn't suddenly feel frustrated the way I went about it in the beginning. I should see getting rid of bugs as a way for me to step up as a beginner!

  • The final lesson I learnt from debugging is, "Bugs are not there to stay! So, I must get rid of them with my debugging superpower!"

I hope you learnt something from my debugging adventure. Please comment if you have any suggestions or thoughts... Please also like this post as it would increase its publicity.

FOLLOW ME ON TWITTER https://twitter.com/Golden_builds