Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Data Structures Efficiency! Menu UI

Joseph Kawa
Joseph Kawa
1,807 Points

Why is KaraokeMachine class not in model folder?

Just curious about this, it would seem to be easier to build this directly inside the model folder instead of having to remember to import the song and songbook classes. Is this sort of a best practice?

1 Answer

Mark Rae
Mark Rae
4,503 Points

The idea is to divide up your program into 3 separate segments: model, view, and controller (often abbreviated MVC). The (data) model is just storage structures, no real behaviors. The view handles only the way things appear to the user. Finally, the controller deals with the logic between the two. Rough example: you click a "delete" button in the view, the controller understands the button and changes the model to remove the element and tells the view to show it as deleted.

I'm not surprised you found it confusing. I thought it was odd that the videos started using this framework without explaining what they were doing first.