misunderstanding
jackmaessen
✭✭✭
---Programmer and his wife---
[wife]: "Darling , could you please go to the supermarket and buy a bread? We don't have a bread anymore"
[man (programmer)]: "Allright, i will take a walk to the supermarket."
[wife]: " Ohhh, before i forget: If they have eggs, bring 6 of them"
Back home:
[wife]: "But darling, why did you bring 6 breads?"
man: "They did have eggs..."
This is how the programmer thinks:
<?php
$aldi = new SuperMarket();
$basket = new Basket($aldi);
if ($aldi->hasEggs())
{
for ($i = 0; $i < 6; $i++)
{
$basket->add(new Bread());
}
}
?>
Result: 6 breads
Who made a mistake? The programmer or his wife? 
1
Comments
Classic logistician joke.
Basket::add()needs to be refactored to include an optional quantity parameter. C++ prototype:bool Basket::add(item_t Item, int quantity = 1);. ThehasEggsmethod seems special case to me. I would much rather see anbool SuperMarket::inStock(item_t Item, int quantity = 1)that could be used for any item in the store./overanalyzing_the_joke