Why you should stop fooing with foo.

Aside from variations of “Hello World”, there is no other evergreen programming concept such as foo and bar. Variable names for the ages, ‘Foo’ and ‘Bar’ have been hanging around a computer screen since there was a computer screen to appear on. Their reign has been long and exceedingly arduous.

Foo and Bar, the tyrants of ambiguity now, but there once was a time when foo and bar were good, useful things. When you were first learning how to create a function and the concepts of programming themselves. Who hasn’t made a little function to add two numbers together and return a result. Something like the following was certainly in my first steps.

function multiply(number1, number2){
  var foo = number1 + number2;
  return foo;
}

Learning aside, haven’t we moved past the point of tutorial and into the realm of the real? So why do we keep naming stuff Foo and Bar? eh? It’s not doing you any favors to ambiguously name your variables and functions anymore.

So the obvious question would be: “What will do me some favors then.” Descriptive variable and function names of course! Make your names into specific statements on what/why they exist. Stuff like temporaryReportArray, dataSourceViews, or reportBuilder.

Don’t shy away from longer names too, with auto complete in most IDE’s you can name things with impunity like reportBuilderDramaticTextLineView, phoneBrowserUserAgentParsedArray, or reversePolishNotationConversionUtility. So go wild and crazy out there, naming your variables explicitly is über helpful in figuring out what they do. It’s the next best thing to well commented code.

In closing, please consider this Hacker Koan (Referred to as the “Ice Cream Koan”). All variables are just names to the system, so we should be the ones giving them meaning for the coders that will come after us.

A cocky novice once said to Stallman: “I can guess why the editor is called Emacs, but why is the justifier called Bolio?”. Stallman replied forcefully: “Names are but names, ‘Emack & Bolio’s’ is the name of a popular ice cream shop in Boston-town. Neither of these men had anything to do with the software.”

His question answered, yet unanswered, the novice turned to go, but Stallman called to him: “Neither Emack nor Bolio had anything to do with the ice cream shop, either.”