Tag Archive for coding heuristics

The Law of ‘S’

For me, a lot of the discipline about programming is about finding useful heuristics for a large number of circumstances. Today, was tracking down an error in someone else’s code that my usual heuristic would have saved me from. It involves the letter ‘S’.

Let’s say, for the sake of argument, that I’m making a banking application. And let’s say that I have to name something: a variable, a CSS class, an XML node, or a JSON property. In some circumstances, it might be meaningful to say “account” and in some circumstances, it might be meaningful to say “accounts”. Here’s my rule. If both forms of the word seem reasonable in context, then I always use the singular. And then, later, when I have to apply the CSS class, or read the XML node, I’ll know what form I chose because I’ll know I followed the rule.

Unfortunately, there’s one programming problem that I haven’t figured out a good rule for: other people. Other people write code, and aren’t as anal as I am. Bummer.