Sprout Method - lovelejess/trivia GitHub Wiki

“I need to change a monster method, and I can’t write tests for it”

How To Implement:

  1. Identify where you need to make your code change (source method).
  2. Write down a call for a new method that you will implement your new behavior in.
  3. Comment out that method (so that we can test drive it)
  4. Determine what local variables you need from the source method, and make them arguments to the call.
  5. Determine whether the sprouted method will need to return values to the source method. If so, change the call so that its return value is assigned to a variable.
  6. Develop the sprout method using test driven development.
  7. Make the test pass!

Try It Out!

  • Oh no!! There's a defect in the game! If a player ever gets in the penalty box, then he or she will never have a chance at winning the game! Fix this defect by using the sprout method so that if a player does get put in the penalty box then he or she will have a chance at winning!

Next Up: Hidden Dependencies