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.
Sergei Makarov12,718 Points
MVC Pattern. Who is who in Spark?
So, please correct me, if I am not right.
Model - "[..] stores data, that is retrieved according to commands from the controller and displayed in the view."
View - "[..] generates an output presentation to the user based on changes in the model."
Controller - "[..] can send commands to the model to update the model's state (can also be associated to change the view's presentation of the model)."
I believe, i could associate it follows:
Model is concatenated with View through ModelAndView.class; Model we can present as Java Collections Framework (e.g. Map);
View is all that will be parsed of HandlebarsTemplateEngine.class (I mean in this case, as I reference to this very course (html, css ans so on);
Thank you for your answers.
Craig DennisTreehouse Teacher
Hi Sergei Makarov , great question!!
Yeah in our situation the "routes" the lambda that starts with
(req, res) is our controller. It is responsible for controlling the flow and filling out the model (any object) which is used to push into our view (our html, currently rendered by HandleBars, but could be anything).
That help clear things up?