Question

In: Computer Science

C)    Explain MVC architectural pattern and its components. Draw a diagram that describes the pattern. Describe...

C)    Explain MVC architectural pattern and its components. Draw a diagram that describes the pattern. Describe the behavior of MVC by using online shopping application that has the following responsibilities: browse catalog, add item to shopping cart, remove item from shopping cart, display shopping cart. State the two advantages and two disadvantages of using this pattern.

Solutions

Expert Solution

Model View Controller or MVC as it is popularly called, is a software design pattern for developing web applications.

A Model View Controller pattern is made up of the following three parts −

Model − The lowest level of the pattern which is responsible for maintaining data.

View − This is responsible for displaying all or a portion of the data to the user.

Controller − Software Code that controls the interactions between the Model and View.

MVC is popular as it isolates the application logic from the user interface layer and supports separation of concerns. Here the Controller receives all requests for the application and then works with the Model to prepare any data needed by the View. The View then uses the data prepared by the Controller to generate a final presentable response. The MVC abstraction can be graphically represented as follows.

The Model

The model is responsible for managing the data of the application. It responds to the request from the view and it also responds to instructions from the controller to update itself.

The View

It means presentation of data in a particular format, triggered by a controller's decision to present the data. They are script-based templating systems like JSP, ASP, PHP and very easy to integrate with AJAX technology.

The Controller

The controller is responsible for responding to the user input and perform interactions on the data model objects. The controller receives the input, it validates the input and then performs the business operation that modifies the state of the data model.

The following figure illustrates the interaction between Model, View and Controller.

Suppose in out application we have design five web pages i.e. welcome page (home page entry point to our application where our main categories of products will be shown), Category page (which will show us the list of different products also it will show us shopping cart option and proceed to checkout option), cart page (which will show us the list of all the product items which we have selected for purchasing),checkout page (which will be used to collect the user personal information as well as it will provide the order summary) and confirmation page (which will show the information that his order has been successfully placed) (Figure).

Before we start the development of application we should decide that which type of architecture we should use to develop our application. We should examine the functional components of our application and determine the way through which they will communicate with each other.There are many design patterns are available which can be used to develop an application. Here we are going to use MVC architecture pattern.

MVC pattern divides our application into three major components i.e. Model, View and Controller. Model is used to communicate with our database. View is used to get data from model and present it to the user. And finally, the controller is used to define the application behavior. It interacts with the inputs of the users. Normally in web-based application user’s inputs are HTTP GET and HTTP POST. Detail about the

Advantages

1. Faster Web Application Development Process:

MVC offers support for rapid and parallel development. So, developing web applications using the MVC model it is possible that one developer work on the view while the another can work on the controller. This helps for easy implementation of the business logic of the web application. It surely benefits developers for completing the web application three times quicker compares with the applications that are developed using other development patterns.

2. MVC Web Application Supports Asynchronous Technique:

.Net developers can integrate MVC architecture with JavaScript Framework. It means that MVC applications can be made to work even with PDF files, site that runs only on the specific browsers, and also for the desktop widgets. MVC also allows using the asynchronous technique, which allows web developers to build faster loading web apps.

disadvantages

1)Increased complexity

2) Inefficiency of data access in view

3) Difficulty of using MVC with modern user interface.

4) Need multiple programmers

If you have any query regarding the answer please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.


Related Solutions

Draw a UML diagram that describes a class that will be used to describe a product...
Draw a UML diagram that describes a class that will be used to describe a product for sale on Glamazon.com. The product has a name, a description, a price, ratings by many customers (1 to 5 stars), and a group of customer comments. New products have no ratings or comments by customers, but do have a name, description and price. The price can be changed and more customer ratings and comments can be added. A global average rating of all...
draw the block diagram of the CRO and explain the different components
draw the block diagram of the CRO and explain the different components
Choosing the best architectural style draw an architectural diagram for the following scenarios using MS Visio:...
Choosing the best architectural style draw an architectural diagram for the following scenarios using MS Visio: A vending machine used by passengers at a railway station. A-Zoom application conferencing system that allows video, audio, and computer data to be visible to several participants at the same time.
a)Draw the diagram and describe the key components of a PLD. b)Describe the main advantage in...
a)Draw the diagram and describe the key components of a PLD. b)Describe the main advantage in using PLD deposition versus other Physical Vapour Deposition methods.
Describe the key concept of system approach and draw a diagram to illustrate the key components...
Describe the key concept of system approach and draw a diagram to illustrate the key components and sequence of a system approach. Discuss the effects of diversity within a group on group performance.
What is homeostasis ? Draw a simple labelled diagram and briefly explain what are the components...
What is homeostasis ? Draw a simple labelled diagram and briefly explain what are the components required in a generic homeostatic system? N.B. You may draw this diagram by hand or draw directly on the computer. Please do not copy-paste images from the web or textbooks. A rough sketch is satisfactory; does not necessarily need to be coloured or of printable quality.
What are the other components that can improve the COP. Draw the P-h diagram to explain...
What are the other components that can improve the COP. Draw the P-h diagram to explain the process.
Instruction to assigned to each processor. ARM Cortex-A12 Draw neatly architectural or block diagram of the...
Instruction to assigned to each processor. ARM Cortex-A12 Draw neatly architectural or block diagram of the selected processor. Identify the following listed below features and explain briefly. Pipelining and stages Memory or Cache Fetch Unit and Decode units Instruction issue policy Register Renaming Reorder Buffer Reservation Station Branch Prediction Execution Units Processor speed Number of Cores Number of Threads 36 Levels of cache and separate or shared cache or instruction and data cache Hyper-Threading or TLP
c. With a neat diagram show various components of a separator. Explain briefly their functions and...
c. With a neat diagram show various components of a separator. Explain briefly their functions and utility
Draw a state diagram of the string pattern recognizer, implement it according to the design sequence...
Draw a state diagram of the string pattern recognizer, implement it according to the design sequence of the FSM, and draw a schematic diagram.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT