HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

misunderstanding

jackmaessenjackmaessen ✭✭✭
edited February 2015 in General Banter

---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? ;)

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);. The hasEggs method seems special case to me. I would much rather see an bool SuperMarket::inStock(item_t Item, int quantity = 1) that could be used for any item in the store.

    /overanalyzing_the_joke

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

Sign In or Register to comment.