Webwide is the inclusive forum community for web designers, developers & makers.

Whether you're an enthusiast, in training, or a seasoned pro – you'll fit right in at Webwide. We understand that our community is one of creation which is why we, unlike many other discussion forums, encourage sharing of your own projects and content. Creating a forum account is fast, easy and completely free so you can start participating right away.

Read our Code of Conduct

Free Forum Membership Benefits

  • Participate in hundreds of interesting discussions
  • Network with industry peers and make new connections
  • Show off your own projects and relevant content
  • Get help and feedback for your coding and designs
  • Buy and sell services and resources in the marketplace
  • Participate in our friendly community challenges
  • Earn trophies and work your way up our leaderboards
  • Enjoy exclusive Webwide member discounts and offers
  • ...and so much more!

Check your assumptions

sfcgeorge

Sonic the developer
Gold Member
Joined
Oct 5, 2019
Messages
105
Reaction score
119
Points
460
Location
London, England
Local Time
Today, 06:47
Website
www.sfcgeorge.co.uk
Credits
404
Pronouns
He/Him
Real Name
Simon George
When starting out I'd often spend hours battling an infuriating bug, going deeper down rabbit holes with ever crazier theories of what could be wrong, changing things at random, etc. Then often I'd realise it was something simple like a constant value I'd mistyped which I had assumed was correct.

So my advice is before you start debugging (or when you feel yourself getting into the manic debugging phase) check your assumptions. Everything you think is obvious and correct, check it, work through it methodically step by step. Seems boring and pointless but will save you time more often than not.

  • Output is wrong? Check the input is correct before you check the logic.
  • Formula produces wrong result? Check constants before checking the math.
  • ...
 
  • Hot
  • Like
Reactions: Adam and Sharkie

Mike Rees

Member
Joined
Feb 3, 2020
Messages
45
Reaction score
67
Points
20
Location
Leicester, UK
Local Time
Today, 06:47
Credits
108
I find the shortcut is to have someone else check it. Right from day one of learning, I had a friend who I would swap code with if we were struggling with it. 5 minute later and the problem would be fixed.

That being said, there's a lot to be said for not making assumptions in the first place. It's second nature for me to check inputs, every line of code in areas I think are going wrong, inclusive logic mistakes and other forgiving syntax errors now. I've done it too many times and cost too much money. It's frustrating having to try and convince others with less experience of the value of it, but I imagine my bosses felt the same way with me when I was a less experienced developer.

If something was working and then it wasn't, the most obvious source of error is a human. And it's probably the human that wrote part of it (input or function) in the first place. It takes a little humility to accept that off the bat.
 
  • Like
Reactions: panphora and Adam

sfcgeorge

Sonic the developer
Gold Member
Joined
Oct 5, 2019
Messages
105
Reaction score
119
Points
460
Location
London, England
Local Time
Today, 06:47
Website
www.sfcgeorge.co.uk
Credits
404
Pronouns
He/Him
Real Name
Simon George
Googles "friend". What is friend? Is it on NPM...

That's a different way to look at it, not making assumptions or minimising assumptions. The nuance is stepping back and looking at what assumptions you might have accidentally made. Like whether you're editing the right file in a large project. Or whether you switched to the wrong terminal and you're working in a different directory. Or whether your router has changed the IP address of your device. All kinds of assumptions that can have very little to do with your actual code but can lead you to think there's a but when there isn't.

Yes that's a good learning. In 10 years I think I can count on 1 hand how many times the bug was in the browser, or the programming language, or the database. It's almost always programmer error. Which is infuriating because you're the programmer and it's easier to blame a machine.
 
  • Like
Reactions: panphora

panphora

Member
Joined
Dec 12, 2019
Messages
19
Reaction score
18
Points
5
Location
Boston, MA
Local Time
Today, 01:47
Website
remaketheweb.com
Credits
77
Pronouns
they
I just went through this over the weekend. I had 3 bugs in my application code.
  1. The first bug was making uploads fail in production, but not my dev environment. It was super confusing. I took a huge tour through all my code before coming back to my NGINX rewrite rules and realizing they were appending a string "app_" to a route, but only in production.
  2. The second bug was also making uploads fail. After realizing the error was caused by uploads being too big, I assumed it was an Express.js or my file upload library's default limit, so I increased those limits first. Turns out, however, that it was the default NGINX config. I was only figured this out in under an hour because I scrolled down through the 3rd and 4th StackOverflow answers.
  3. The third bug was the nastiest and took me all Sunday to figure out. This one — you guessed it — was also causing issues with uploading files. 🙂 It was the weirdest thing because this particular type of upload had been working only a few days before. Naturally, I thought there must be a problem with new code that I just pushed up. I checked, but the last code in the repo was from a month ago. I went through dozens of files before finally tracking it down to... new code. Turns out, even though the last update was a month ago, I hadn't deployed the changes until a few days ago (while trying to fix another bug), which is when it stopped working. If I'd just questioned my assumptions early on and gone with my gut at the beginning, I could've saved 3 hours. 😖
 
  • Like
Reactions: sfcgeorge
Top