Friday, November 18, 2011

An Algorithm for Parents

Here is something I sent to a friend whose wife just gave birth:
-----------------------------------------------------------

while (baby.isCrying())
{
baby.Burp();
if (!baby.isCrying())
{
output("your baby had gas");
exit;
}

if (baby.needsDiaperChange())
baby.changeDiaper();

if (!baby.isCrying())
{
output("your baby needed a change");
exit;
}

baby.Cuddle();
if (!baby.isCrying())
{
output("your baby needed a cuddle");
exit;
}

baby.Feed();
if (!baby.isCrying())
{
output("your baby was hungry");
exit;
}

baby.holdAndRockGently();
if (baby.isSleeping())
{
output("your baby was tired");
exit;
}
}

1 comment:

  1. A colleague suggested to me that this might also need a try/catch block with the catch block containing MyDoctor.Call();

    ReplyDelete