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 trialHassaan Ahmad
1,979 PointsWhy is playNext() method made public when it could've been made private as other methods?
playNext() method is made public even when it is only being called from another public method of the same class. Isn't it better to make it private as it is not being accessed directly anywhere out of the KaraokeMachine class?
1 Answer
Steven Parker
231,198 PointsWow, old question. It may be that only the folks tagged will ever see the new comment.
But even if the current implementation only calls a method from inside the same class, one reason to make it public might be if it serves a function that might be of use to future code.
I suspect that's what the instructor had in mind when he said "Let's make it public, so anybody can call this one, if they wanted to."
Tonnie Fanadez
UX Design Techdegree Graduate 22,796 Pointsgood thinking, yes for future uses....
<noob />
17,062 Points<noob />
17,062 PointsGood point, I also thought about this as we didnt use this method outside of the KaraokeMachine class. any one of u knows? Steven Parker Tonnie Fanadez Eric McKibbin