Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Seriously? An ancient programming joke, with a gratuitous off-by-one error?


It's not gratuitous. One jug + one dozen = 13 jugs.


jugs = 1; if (have eggs) { jugs = 12; }

Get a dozen, not a dozen more.


  cart.addJugs(1);
  if (haveEggs)
    cart.addJugs(12);
Now the cart has 13 jugs.


I'd say that "get a dozen" implies "jugs = 12" and not "jugs += 12". If you wanted to get a dozen more, you'd say "get a dozen more"


This is why we don't program in English.


And why it is so hard to write a good specification.


"get a dozen" implies "jugs += 12"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: