The Smoke Detector
  • About
    • About TSD
    • Contact us
  • Art / Design
  • Beauty
  • Fashion
  • Interviews
  • Columns
  • Coding
The Smoke Detector
  • About
    • About TSD
    • Contact us
  • Art / Design
  • Beauty
  • Fashion
  • Interviews
  • Columns
  • Coding
  • Coding

10 debugging tips that helped me

  • Ivona Josipovic
  • 29 November 2022
  • Don’t assume – debugging is like science, not magic. You can spend a lot of time trying to assume what the issue is and tweak your code (only to undo it all later), or you can take a more systematic approach to find the problem. It’s tempting to try to guess what the issue is and try to fix it quickly, but this way usually costs you more time in the long run.
  • Stay calm. Sure it can be very frustrating, but debugging is part of the process and a great learning experience. It is also a crucial skill in programming so put on your detective hat and start looking for clues.
  • Don’t be afraid of changing your code. You already have a bug,  so you have to do something and while changes can feel scary this is a great time to implement them.
  • Pay attention to the error message – it can tell you quite a bit.  Also, when writing the code meant to handle potential errors in your program make sure to provide sufficient error information.
  • Read the code and documentation. This one compliments rule nr.1. Read the code carefully and if you are working with a library or an API or any external piece with documentation – read the documentation and follow what it says without assumptions. Just because in Vue you might use X, that does not mean that it’s the same in React.

Cartoon Coding GIF by Scaler - Find & Share on GIPHY

  • Use descriptive names – it will make reading and understanding the code so much easier later on. That is more of a writing tip, but it sure makes debugging easier when you can follow along instead of having lots of weirdly named variables and functions that do / store who knows what.
  • Console.log is your best friend. Console logging in different areas of your program can really help you understand what happens with your code. Do certain sections get executed, what values are returned, and what is the data type?  If you do console log more values, write a short message before the variable to help you know which message comes from where in the code.
  • Is it the right data type? This one is especially useful for JavaScript as it is a dynamically typed language. You can just declare a variable without the need to specify its data type. The types are automatically converted during script execution and that can sometimes be tricky as what you might expect to be returned as a number will end up being a string. So console log ‘typeof’ that variable whenever you might not be sure.
  • Google is your other best friend as whatever problem you’re facing someone has encountered it before. I mean, what would we do without Stack Overflow, right? Googling will not only help you find a potential solution but will also lead you to trying out and learning new things which is always great.
  • Split your code and think about the structure from the beginning. It might feel hard when starting to learn to program, but it becomes easier with practice. First, make sure that you split your functions so that each does just one task, and as you progress think about using modular programming to separate and structure into manageable smaller pieces.
Share
Tweet
Pin it
Share
Share
Related Topics
  • 10 tips
  • better code
  • console log
  • data type
  • debugging
  • error
  • javascript
  • modular programming
Ivona Josipovic

Ivona Josipovic is a co-founder of The Smoke Detector, writer, fashion stylist, social media manager, curious creature, chocolate lover.

You May Also Like
View Post
  • Fashion

Nordgreen Copenhagen watch review

  • Ivona Josipovic
  • 8 August 2020
View Post
  • Fashion
  • Interviews

Interview with Joanna Bark and Elena Ekström, founders of Bukvy

  • Ivona Josipovic
  • 30 March 2020
View Post
  • Fashion

The evolution of male red carpet style

  • Ivona Josipovic
  • 18 March 2020
View Post
  • Fashion

Christian Louboutin Exhibition, L’Exhibitioniste – Paris 2020

  • Ivona Josipovic
  • 25 February 2020
View Post
  • Fashion

Best Fashion documentaries – part 3

  • Ivona Josipovic
  • 6 March 2020
View Post
  • Fashion

Best handbag brands to know in 2020

  • Ivona Josipovic
  • 11 February 2020

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Featured Posts
  • 1
    • Fashion
    Nordgreen Copenhagen watch review
    • 8 August 2020
  • 2
    • Fashion
    • Interviews
    Interview with Joanna Bark and Elena Ekström, founders of Bukvy
    • 30 March 2020
  • 3
    • Fashion
    The evolution of male red carpet style
    • 18 March 2020
  • 4
    • Fashion
    Christian Louboutin Exhibition, L’Exhibitioniste – Paris 2020
    • 25 February 2020
  • 5
    • Fashion
    Best Fashion documentaries – part 3
    • 6 March 2020
  • 6
    • Fashion
    Best handbag brands to know in 2020
    • 11 February 2020
  • 7
    • Fashion
    Best fashion quotes with strong messages
    • 31 January 2020
  • 8
    • Fashion
    10 ways fashion has changed in the 2010s
    • 4 January 2020
  • 9
    • Art / Design
    • Interviews
    Interview with Elisabeth van Aalderen, the photographer behind Vitiligo photo project
    • 16 December 2019
  • 10
    • Art / Design
    Illustrators celebrating womanhood we love following on IG
    • 10 January 2020
Reflection. 🌴
The world need more love. BLM! 🖤 Regram from @inesabouchard .
Don't miss reading our interview with the founders of the amazing @bukvybag brand. This female-led accessories brand is based in Stockholm and focused on creating practical pieces for everyday life. 😍 Link in bio. #bukvy #bukvybag #interview #femalefounders
Daydreaming of places as this one... 💙 Follow the super talented @salvalopez for more amazing images like this... #photography #pink #daydreaming
Gorgeous images by @nina_zimolong. 💟 In case you missed our interview with the talented photographer go to our site to read it. #photography #interview #love #stunning
Lazy Sunday mani inspo from @vanessahong. Nothing like some cute polka dots for mood boosting, right? 😍 #cute #manicure #loveit #polkadots
The Smoke Detector
  • About
  • Art / Design
  • Beauty
  • Fashion
  • Interviews
  • Columns
  • Coding
The Smoke Detector covers photography, fashion, art, design, cool people and places

Input your search keywords and press Enter.