‘Foo’ considered harmful

Naming is the most important part of design. Concise yet meaningful names are hugely important.

One of my favorite tips is to shortcut ‘rename in file’ in Eclipse as Ctrl-~.

For parameters or variables, however, I prefer either math names or meaningful names — customer, name, customerName, id, value, val, x, str, text, obj.

I never ever use ‘foo’. Is foo a name, an ID, a value, an object? “Foo” is no shorter, but is definitely less informative.

When “foo” is used, I sometimes get the impression that the fact that it’s meaningless is almost a conceit. This seems to me like an anti-pattern in naming & communication.

Leave a Reply

Your email address will not be published. Required fields are marked *