Sprout Method - lovelejess/trivia GitHub Wiki
“I need to change a monster method, and I can’t write tests for it”
How To Implement:
- Identify where you need to make your code change (source method).
- Write down a call for a new method that you will implement your new behavior in.
- Comment out that method (so that we can test drive it)
- Determine what local variables you need from the source method, and make them arguments to the call.
- 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.
- Develop the sprout method using test driven development.
- 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