Debugging Tool: Sentinel Value

31 August 2017 by Amy

Today's project was working through some bugs and unexpected behavior in my JavaScript project which is a to-do-list. The tutorial is Practical JavaScript at Watch and Code. I'm currently working through the Version 9 modules.

The problem:

It took me a while to figure out what was going on, but after getting absolutly stumped, I asked for help. My helper decided to introduce a sentinel value to my code, not realizing I had no idea what a sentinel value was. As that value populated into my code, my blank stare was a good indicator of a knowledge gap; it wasn't the reaction expected. So we had a lovely chat about the value of this debugging method, and how it's common and even good to use values that would otherwise not be valid. Xbox One users recently expirenced a rather strange error message referencing My Little Pony, which was of course a sentinel value intended for internal use only.

What I learned:

Because my sentinel value wasn't getting overwritten, it was a good indicator I should examine my code that should be repalcing said value. After some examination there were a few problems, including a problamatic line that reset the value to another before I used it and a capital letter that caused the computer to think I wanted to use a different value (whoops!).

I also learned the value of this tool, which I'm excited to add to my toolbox. It doesn't matter when you assign a value to empty quotation marks if you plan to overwrite that value anyway, but in the future, I'll probably throw in a sentinel value as I found its presence very helpful once I knew how to use it.

Additonal reading:

Sentinel value | Wikipedia