577 karma · joined August 31, 2011
int get_at(const struct foo_t *foo, int pos) { return foo->len >= pos ? -1 : foo->data[pos]; }
!(foo->len >= pos) = (pos >= foo->len) => foo->data[pos] = foo->data[foo->len + x] where x >= 0, which is undefined.
It seems the author got caught up trying to be tricky, and the fix has the bonus of reading more naturally:
return (pos < foo->len) ? foo->data[pos] : -1;
It is late though. Maybe my brain isn't in gear...
Note it's the only tab completion script I've written, and it's probably a hack :P
Looks like I wrote the tab-completion script on my work machine. I don't have access to it right now, but if I remember when I do have access I'll pastebin that as well.
I reckon the software industry could give that last claim a run for its money. Ignoring incompetence, sometimes there simply isn't an elegant solution that fits time, budget, stability and technical debt constraints, yet it's somehow not an estimate issue.
In conclusion I thought the article made enough of a point to be worthwhile, though maybe it's been done to death and could have been delivered in a less snarky fashion
This has revealed many bad habits and allowed us to correct them through review comments prior to changes being submitted. It's also shown me just how "legacy"[2] our code-base is, but thanks to sonarqube (which runs PMD and FindBugs as part of its analysis) we're improving.
[1] http://www.sonarqube.org [2] http://www.amazon.com/gp/aw/d/0131177052