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 trialAbdul Makba
1,293 Pointsgame object?
Instead of sending the game through the constructor, could we not have created a game object directly in the prompter class?
1 Answer
Dane Parchment
Treehouse Moderator 11,077 PointsYou could, but it wouldn't make much organizational sense, the prompter's job is to prompt, not actually handle the game logic. In computer science we call this The Separation of Concerns Principle, and it is an extremely important principle. Basically your program should be split into distinctive parts and each part should simply be in charge of it's own thing, or concern. There are many reasons for this but the most important one is for maintenance as objects that do things outside of it's scope can become harder to debug and add/remove to.
In short The prompter is it's own thing, it is in charge of prompting the user, not for creating the game itself.
Abdul Makba
1,293 PointsAbdul Makba
1,293 PointsThat makes sense, thanks for your reply.