MVC Pattern

Model–view–controller (usually known as MVC) is a software design pattern that is commonly used for developing web applications. In fact, most web development frameworks (including Spark) support this design pattern by default (i.e. they expect you to follow it).

This pattern is used to separate application's concerns:

  • Model represents an object or JAVA POJO carrying data.
  • View represents the visualization of the data that model contains.
  • Controller is the bridge between the model and view. It controls the data flow into model object and updates the view whenever data changes.

In our application, the Controllers are the route methods (and the logic therein). We are building the Views using handlebar templates. Given our wireframe, we need two views: a homepage (or landing page) and the search page (contains retrived results and a search bar to repeat the search). We will build these next.