Friday, April 2, 2010

Exercise 12: Modelling with UML or MVC?

Examine the Use Case in Figure 4 and explain the MVC architecture of the online bookstore (the model the view and controllers) needed to Lookup Books and Add to Shopping Cart .

There appeears to be a typo in this question as the online bookstore model is actually represented at Figure 10 in the study guide. In any case the figure referenced in this question is presented below.



The MVC architecture is a widely used architectural approach for interactive applications that distributes functionality among application objects so as to minimise the degree of coupling between the objects. This architecture has been discussed extensively in previous blogs, but as a refresher, the MVC architecture divides applications into three layers: model, view, and controller. Each layer handles specific tasks and has responsibilities to the other layer. These are as follows:
  • The model represents business data, along with business logic or operations that govern access and modification of this business data. The model notifies views when it changes and lets the view query the model about its state. It also lets the controller access application functionality encapsulated by the model. In the online bookstore application, the shopping cart and database access object contain the business logic for the application.
  • The view renders the contents of a model. It gets data from the model and specifies how that data should be presented. It updates data presentation when the model changes. A view also forwards user input to a controller. The online bookstore pages format the data stored in the session-scoped shopping cart and the page-scoped database (for lookup books) which represent the view
  • The controller defines application behaviour. It dispatches user requests and selects views for presentation. It interprets user inputs and maps them into actions to be performed by the model. In a web application, user inputs are HTTP get and post requests. A controller selects the next view to display based on the user interactions and the outcome of the model operations. In the onlne bookstore application a series of servlets represent the controller. These examines the request URL, creates and initialises a session whether this be the shopping cart or lookup books.

No comments:

Post a Comment