Last week I put the finishing touches on an update to one of our free themes on WordPress.com, Independent Publisher 2, and I thought that everything was working as they should after my changes. I had made a significant modification to the existing parts of the theme to warrant a full test of its capabilities before deploying – and I was confident that I’d covered all the scenarios.
That was on Friday…
Cue 4 o’clock Monday morning!
Thankfully, one of my colleagues lives and works ahead of me in terms of timezones, and reported the issue. The problem came about as a result of an overly strict set of logical operators in an if statement. After a cup (or two) of coffee while I was thinking about how to fix this – my memory reminded me about the concept of sentinel values.
I’ve always liked this concept because when I think of a sentinel, I think of something strong, immovable, and protective. And using that in an if statement conditional, gives me confidence that the comparison will validate correctly every time and protect the code from failure.
As it turned out, this was a good solution to the problem, and I deployed the fix pretty quickly. 🙂 Sometimes we don’t always think we’ll use theoretical concepts from university, but I’m really glad I paid attention that day!