Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rymawby/e2c39b965cc052742a6da7f7acfc1e58 to your computer and use it in GitHub Desktop.
Save rymawby/e2c39b965cc052742a6da7f7acfc1e58 to your computer and use it in GitHub Desktop.
Padawan to Jedi: Extract Method refactoring technique

Refactor the following using the "Extract Method" technique.

function welcomeToTakodanaCastle()
{
  while _guests.hasNext()
  {
    guest = _guests.next();
    if(guest.isSmuggler)
    {
      _maz.says("Are you selling anything today " + guest.name + "?");
      if(guest.isSellingSmuggledGoods)
      {
        _maz.buy(guest.goods);
      }
    }
    else
    {
      _maz.says("Hello there " + guest.name);
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment