Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Objects (Retired) Delivering the MVP Refactoring

Can someone explain this lesson to me?

I understand that this video was about fixing the "no letter" bug, but why did Craig have to create a new method? Couldn't he have just modified the old applyGuess method to accept a string and throw an exception?

Sina Maleki
Sina Maleki
6,135 Points

Hi Stephanie Fu. Craig create a new method because he wants to have two method with two responsibility, one of them works with strings and the other one works with characters. Best

1 Answer

Hi Stephanie, as per Sina. You are correct the applyGuess method could've just been modified to accept a string, but by using method overloading (two methods with the same name that accept different inputs) the application is able to accept both a string or a char which your solution wouldn't do. Alex