Debugging Bugging You?

A beginners guide on debugging

Netaly Ramirez
The Startup
4 min readSep 3, 2020

--

When I first began my programing journey I was both amazed and baffled by the sheer amount of documentation I would have to sift through. I was given some direction when my friend directed me to some free pre-boot programs. These programs gave me some structure, and practice understanding logic with the help of their test specs. I quickly came to realize that I often began to “code” without fully thinking through my game plan. This as you may already know is crucial in how much time you spend trying to solve a problem or as a result of ill-planning creating your own little army of bugs.

1. Read Your Prompt And Understand Your Deliverables

Read your problem, then read it again. Take it one step at a time and plan out how to achieve that step. “Computers are as dumb as a rock” — Tracy Collins Computers will take everything you type literally you have been warned. We, however can understand more through less and in so doing, tend to think declaratively. While in order for your program to work effectively you need you to think more imperatively. For example let’s say you go into a Bodega and ask for a BLT, this request is considered declarative. The imperative counterpart would be to request a BLT, on a whole wheat roll with the inside of the bread scooped out, lightly toasted, 1/4 tbs of mayonnaise, bacon cooked well done, and a side of extra sliced tomatoes. One way to get this habit going is to sue-do code your solution/thought process inside your code.

2. Read The Error!

After reading lines of code for varied amounts of time some things can become out of focus. Read your errors with patience and critical thought. Think, “what is my screen trying to tell me? ”, “Is there something missing?”, and “what can cause this error?

3. Check Your Spelling / Check Your Syntax

Simple enough right? You wouldn’t believe how often a simple lowercased letter or a comma can throw your whole logic out the window. If you are anything like me when I first began to code, it is important that you stay cool, calm, and collected in the face of the evil red errors. Take a moment to read over your code, maybe you were just missing a letter.

4. Backtrack

Think, up to what point was everything working? Take one step back, and comment out the newest segment of code. If your code still won’t run, go to another segment and comment that out. Rinse and repeat until you find which line of code is failing you. These steps will help you narrow down the source of your error. Note: If you are using a mac one way to comment out a large section of code is by highlighting the desired section and cmd + / . This will work in most programming languages.

5. Do not be afraid to console.log( )

If you have made a function or method that is expecting an argument, now is the time to use console.log()or a debugger. This works wonders when you want to see what you are receiving as an argument. You can even use this as a way to check if your function or method is being properly called 😉. If you don’t get to your debugger or your console.log() your function probably never ran.

6. Check Your Scopes

Depending on what language you are learning, variables can be accessed differently. That being said, in JavaScript, a variable defined within a function belongs to that function and can only be referred to it by its inner components. For example, you have access to your toilet

2020 started like this

paper in your bathroom (toilet paper = variable, your house is your bigger function) and you can use that toilet paper in any area in your house. Your neighbor on the other hand can’t come into your home and use your toilet paper for nefarious reasons.

7. Make Google Your Best Friend

Google will be there for you. Google will treat you right. In Google we trust. Googling your question might work occasionally; however, it may not always yield the answers we are looking for. Instead try to google the action you need, and the programing language you are working in. If you know of certain documentations such as MDN, include that in your search.

8. Take a Break!

I know it’s hard to take a break when you think you haven’t made any strides in your code. You may feel like you don’t deserve it, but be kind to yourself you do deserve it. A simple trip to your fridge, or even making yourself a drink can give you a new set of eyes to handle your problem. And if you really don’t want to take a physical break, try a different problem.

Over the course of this year I have become more comfortable with errors. Seeing errors had once filled me with dread and anxiety, but now getting a different error gives me hope. This becomes a sign of progress! Don’t ever be afraid of getting errors, or breaking things. Every error is part of the learning process. Understanding why your code wouldn’t work is imperative for your programing journey. I’ve been recently reminded by a project partner “You have to break a few eggs to make an omelette”. Keep in mind it gets better, you stop making the same mistakes, and instead make new ones! Good luck on your road to becoming a programmer, and may the odds be ever in your favor.

--

--

Netaly Ramirez
The Startup

You will eventually get to your destination if you continue to tackle it one step at a time. Find me on Twitter @NetalyCodes