My printer is unable to clean 51. It won’t work, and all it says is “Unable to Clean 51.”
Here’s my suggestion for finding such useless error messages in a code review: Write a script to extract all string literals from your source code, then read over the output. The beauty of this approach is that the reviewer sees the text without the context of the surrounding code, just as the user does. Ideally someone who is not a programmer would review the output strings. I would hope someone who ran across “Unable to Clean 51″ would flag that as something that doesn’t make sense.
It’s not hard to write a script to pull out string literals. If you’d like, you could use the script that accompanies my Code Project article PowerShell Script for Reviewing Text Shown to Users. That script tries to filter out strings that are not user output, such as file paths. It’s a pretty crude script, attempting to handle source code written in several languages. It will have a few false positives, and a few false negatives, but it works quite well for a short script. (Code Project’s “browse source” tab doesn’t work for PowerShell source. You’ll have to download the code to read it.)
Whenever I recommend this script, I run into a few objections that I’ll address below.
Q: Wouldn’t it be better if programmers put all user output text in string tables rather than putting user output text in the main body of their code?
A: Yes, but that takes more effort, and it’s not how most programmers work. And even if you have a policy to put all output strings in a resource table, you’d need something like this script to enforce the policy.
Q: Wouldn’t it be better to have a real parser extract the strings rather than doing regular expression guesswork?
Q: Wouldn’t it be better to use a spell checker that’s built into your IDE?
A: No. The purpose of the review is not just to check spelling. You also want to catch grammar errors and unhelpful messages.
Q: Wouldn’t it be better to do a complete code review?
A: Yes and no. Complete code reviews are great for overall code quality. But they take a lot of effort and don’t happen often. A review of just the extracted strings takes far, far less time. Also, viewing the output strings out of context is better for catching unhelpful or ungrammatical messages.
Q: Isn’t this simplistic? Doesn’t every company do something like this?
A: If they do, why do I continually find spelling errors, grammatical errors, and unhelpful messages in the software I use?