Given that SaaS apps have always been view centric and have always relied on a

Given that saas apps have always been view centric

This preview shows page 76 - 79 out of 502 pages.

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 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.
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. MVC is appropriate for interactive SaaS apps with a variety of model types, where it makes sense to situate controllers and views along with each type of model. Other architectural patterns may be more appropriate for smaller apps with fewer models or a smaller repertoire of operations.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture