DEV Community

Alan Johnson
Alan Johnson

Posted on • Updated on • Originally published at nalanj.dev

Bug Pattern: Ignoring the default case

I'm going to be writing up bug patterns as I see them, as a bit of a personal learning project. When I create bugs, what caused me to create them?

This first one I'm going to call Ignoring the default. Imagine this scenario:

  • You find a tricky bug
  • You spend a while debugging it
  • Aha! You finally find the problem. Fix it. You test the reproduction case. You ship the fix.
  • Time elapses.
  • A very common case in your application isn't working correctly.

I did this yesterday. What was the problem? I ignored the default case. I got so focused on fixing the error case that I forgot to test the default case and rushed to shipping the fix.

This actually came up due to two issues:

  • I ignored the default case when I was preparing the fix.
  • My test coverage didn't cover the default case.

In this particular situation I'm not sure a test for the default case would have made that much sense, but still. I ignored the default case.

Top comments (0)