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 trialkabir k
Courses Plus Student 18,036 PointsHow do we determine that a feature request e.g. SongRequest (in our Karaoke project) will be a model or not
How do we determine that a feature request (or a feature) e.g. SongRequest (in our Karaoke project) is a model or not (i.e. something else, like the KaraokeMachine)?
Is there a way to say one feature should be a model and another should be something else?
1 Answer
Ryan Ruscett
23,309 PointsHey,
So this works a bit differently than how you are thinking. Think of a "Model" as an object. Than say what is an object? For example.
A model car. A model car comes in a bunch of different pieces. Each piece has a purpose when it comes to building the car. The hood, the wheels etc. When we built the car, we have a collection of pieces that together make a model. So a model can be individual pieces of data that represent something else. This something else is an object.
When I go to create an object of a skateboard in Java. I know a skateboard has a deck, trucks and wheels. This means that I can create a model of a skateboard using these three items. The model is a representation of the object. A skateboard object is not just wheels, not just a deck or a set of trucks. it's all three items. All three items make an object. But how do I frame that object. How do I say what things make up the object. I do this with a model. I can model an object by saying a skateboard is three items. When I have all three I have an object.
They are really very similar and the differences are not that important. Models come from the idea of MVC where you have model views controllers, where models represent sets of data from a database or something. Well an object represents a set of data too. It's a fine line.
Does this help understand it a bit better?
kabir k
Courses Plus Student 18,036 Pointskabir k
Courses Plus Student 18,036 PointsYes, thanks Ryan. It helps. So why do we have the KaraokeMachine.java file outside of the model package and not inside of it even though it is part of the Karaoke project?