Since RottenPotatoes has only one model Movies it also has only one controller

Since rottenpotatoes has only one model movies it

This preview shows page 86 - 89 out of 517 pages.

next to the user, and supplies that view with any necessary information. Since RottenPotatoes has only one model (Movies), it also has only one controller, the Movies controller. The actions defined in that controller can handle each type of user interaction with any Movie view (clicking on links or buttons, for example) and contain the necessary logic to obtain Model data to render any of the Movie views. Given that SaaS apps have always been view-centric and have always relied on a persistence tier, Rails’ choice of MVC as the underlying architecture might seem like an obvious fit. But other choices are possible, such as those in Figure 2.9 excerpted from Martin Fowler’s Catalog of Patterns of Enterprise Application Architecture . Apps consisting of mostly static content with only a small amount of
Image of page 86
dynamically-generated content, such as a weather site, might choose the Template View pattern. The Page Controller pattern works well for an application that is easily structured as a small number of distinct pages, effectively giving each page its own simple controller that only knows how to generate that page. For an application that takes a user through a sequence of pages (such as signing up for a mailing list) but has few models, the Front Controller pattern might suffice, in which a single controller handles all incoming requests rather than separate controllers handling requests for each model. Figure 2.9: Comparing Web app architectural patterns. Models are rounded rectangles, controllers are rectangles, and views are document icons. Page Controller (left), used by Sinatra, has a controller for each logical page of the app. Front Controller (top center), used by Java 2 Enterprise Edition (J2EE) servlets, has a single controller that relies on methods in a variety of models to generate one of a collection of views. Template View (bottom center), used by PHP, emphasizes building the app around the views, with logic in the models generating dynamic content in place of part of the views; the controller is implicit in the framework. Model-View-Controller (right), used by Rails and Java Spring, associates a controller and a set of views with each model type. Figure 2.10 summarizes our latest understanding of the structure of a SaaS app.
Image of page 87
Figure 2.10: Step 2a has been expanded to show the role of the MVC architecture in fulfilling a SaaS app request. Summary The Model-View-Controller or MVC design pattern distinguishes models that implement business logic, views that present information to the user and allow the user to interact with the app, and controllers that mediate the interaction between views and models. In MVC SaaS apps, every user action that can be performed on a web page—clicking a link or button, submitting a fill-in form, or using drag-and-drop—is eventually handled by some controller action, which will consult the model(s) as needed to obtain information and generate a view in response.
Image of page 88
Image of page 89

You've reached the end of your free preview.

Want to read all 517 pages?

  • Spring '19
  • Dr.Marcos

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors