4 ms·
The HN post says uses the word blacklist, but the library itself works like this: isVegan.isVeganIngredient('ham'); // true
by callumlocke 9y ago
The HN post says uses the word blacklist, but the library itself works like this:
isVegan.isVeganIngredient('ham'); // true
- travisjungroth 9y agoSeems like a pretty glaring test case...
- hmontazeri 9y agoham is a product. pork would be the ingredient which is on the list...
- contravariant 9y agoAccording to the website they're linking to, ham can also be an ingredient. Although technically I couldn't find a reference to 'HAM', but rather 'HAM (CURED WITH HONEY, SALT, SUGAR, WATER, DEXTROSE, LACTIC ACID STARTER CULTURE, SODIUM ASCORBATE, SODIUM NITRITE)' [0] [0]:https://ndb.nal.usda.gov/ndb/foods/show/82389 https://ndb.nal.usda.gov/ndb/foods/show/82389
- masklinn 9y agoYes, because it has a blacklist: it has a list of non-vegan ingredients and assumes everything else passes. If it had a whitelist, it might tell you that spinach is not vegan instead. With both, it might tell you that both spinach and ham are ?.
- callumlocke 9y agoI know what a blacklist is. Nothing wrong with a blacklist. The problem is that the function is called "isVeganIngredient", and it returns true for "ham".
- ytog 9y agoYes, and that is because of the blacklist. A blacklist can only answer if something is on the list. One could either claim that the function should never return true or that returning true is correct, but the accuracy is unknown.
- masklinn 9y ago> I know what a blacklist is. Nothing wrong with a blacklist. The problem is that the function is called "isVeganIngredient", and it returns true for "ham". If you "know what a blacklist is", how can you fail to understand that it returns true for ham because it's a blacklist and thus assumes any missing item is OK? Even if they add "ham" to the list, you'll always be able to find stuff that's not on the blacklist, because that's how blacklists work. Hákarl? Not on the blacklist, will be marked as vegan. Whale? Not on the blacklist, will be marked as vegan. Pizzle? Not on the blacklist, will be marked as vegan. A blacklist means you'll have false negatives (items will pass which should not), and a whitelist means you'll have false positives (items will be flagged which should not). If you can't actually test properties, the only question you're left with is which failure mode is preferrable, but it's one or the other. And in my opinion, things which have to do with health or safety are the latter (you'd rather avoid something which turns out to be safe than allow something which is not).
- callumlocke 9y agoWe completely agree about what a blacklist is. I am saying the function should not be called isVeganIngredient if it returns true for ham. It’s misleading. It’s bad design. Two possible solutions: 1. Invert the return value, and change the function name to isKnownNonVeganIngredient (and take similar steps for the other functions). 2. Even better, scrap the functions entirely, and just release the data (e.g. publish a dumb JSON package on npm called non-vegan-ingredients), so people can use everyday array methods to consume it however they want. I’m not the one downvoting you btw.