‘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.

Bad auto-completions in Eclipse

Eclipse recently has suffered increasing numbers of questionable autocompletions — sometimes auto-wrongly replacing  perfectly good code typed by the developer.

While there might be a few underlying issues, I found replacing “map.put()” with “map.compute()” particularly annoying and went to investigate. Here’s the solution.

Continue reading

HTTP Status Reason broken in Tomcat 9

Just today, I found the “amusing” fact that Tomcat server developers have taken it upon themselves to delete support for the HTTP Status Reason.

Think “200 OK” or “404 Not Found”. Even for applications sending a reason & clients expecting it, Tomcat is coded to explicitly drop the value — sending just a bald 200 or 404.

Unsurprisingly for those with the slightest knowledge of protocol compatibility, this is now breaking clients in the wild.

Continue reading