DEV Community

jazzbozner
jazzbozner

Posted on

The Code to Blogging 0.2

As I finished up my second coding challenge with Ruby on Rails I absolutely realized I need to work on my debugging abilities. Having the skills to debug your issues is so critical in the world of software development; some critics would even say that it is one of the most important skills a developer could have. And so, I set out to understand the principles of debugging and how I might better my skills.

First, I must add that I felt confident about the material that we were working with. For the most part our cohort was focused on: associations, routing, using RESTful practices, and completing the very basics. I ran into an issue with when it came to displaying nested data in my program; I frantically started to figure out ways of how to debug this problem.

What not do to:

-Keep running your same method over and over asking why it doesn’t work
-Stare at your computer screen blindly
-Randomly change enumerators
-Look around the room for the answer
-Believe that the computer is doing something wrong
-Listed above are instances I caught myself applying while mindlessly trying to debug a problem. Needless to say, I needed to change my ways.

Branching from the article: How to debug for absolute beginners
https://docs.microsoft.com/en-us/visualstudio/debugger/debugging-absolute-beginners?view=vs-2019

After reading into some of the basics of “What to do when you errors occurs or you’re expecting data that isn’t being returned.” one should not jump to certain conclusions, but to break down what you’re trying to achieve. Here are several steps that I now take to reduce my anxieties, as well as accomplish desired goals.

  1. What did you expect your code to do and what happened instead?
    If you run into an error you can lean on your debugging tool to take you to the exact location in which the error occurred. In addition, prepare yourself to step through your code and examine each line.
    Examine your assumptions of how you think your program should be working

  2. Sometimes we assume that since our previous code was working that there shouldn’t be any conflict happening, but by questioning on what we think should be happening might uncover your problem.
    Step through your code

  3. Often times we need to understand what portions of our code is working and where the conflict could be occurring. Using gems such as “binding.pry” and “byebug” can really help you step though your code. Console your program and see what variables, methods, and types of data are occurring.

  4. Google your problem/error
    More often than not, a developer has run into the same issue that you have. Stackoverflow and other online resources could be the key that you’re looking for in help fix your problem.
    Don’t simply copy and paste the code in, understand what is happening in the syntax.

  5. Create a sample app
    In order to tune your debugging skills you could create a sample app that with intentional bugs. This will allow you to associate your errors with the exact problems that are occurring.

In conclusion, there is no need to panic when a bug occurs and or when you’re not returning the appropriate information. Take the time to think logically about your problem and take steps in understanding how your code is working and your program as a whole--keep a mindset of “always a beginner”--the constant motivator.

Top comments (0)