8 Apr 2009

Q6. Describe the steps involved with the MVC design approach

Answer:

TutorialsPoint (2009)
describes that the Model View Controller principle divides the work of an application into three separate but closely cooperative subsystems.
Model (ActiveRecord ) :
Maintains the relationship between Object and Database and handles validation, association, transactions, and more. This subsystem is implemented in ActiveRecord library which provides an interface and binding between the tables in a relational database and the Ruby program code that manipulates database records. Ruby method names are automatically generated from the field names of database tables, and so on.
View ( ActionView ):
A 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. This subsystem is implemented in ActionView library which is an Embedded Ruby (ERb) based system for defining presentation templates for data presentation. Every Web connection to a Rails application results in the displaying of a view.
Controller ( ActionController ):
The facility within the application that directs traffic, on the one hand querying the models for specific data, and on the other hand organizing that data (searching, sorting, massaging it) into a form that fits the needs of a given view. This subsystem is implemented in ActionController which is a data broker sitting between ActiveRecord (the database interface) and ActionView (the presentation engine).

The Digram-30 shows the MVC framework as follow...

Diagram-30 - MVC framework downloaded from TutorialsPoint

The other diagram-31 shows the steps in involved with MVC design approach.


Diagram-31 - Step in MVC downloaded from http://www.javapassion.com/rubyonrails/rails_overview_1hour_techday.pdf and http://www.meshplex.org/wiki/Ruby/Ruby_on_Rails_programming_tutorials

The steps are listed below...
  1. A user interacts the ROR Web Pages, for example, submitting a set of form data.
  2. WebServer Dispatcher receives the incoming request (form data)
  3. The Active Controller (Controller) referring the xxx_controller.rb files communicates with Active Record and Active View. The Active Controller also organize the data at this stage
  4. Active Record (Model) sends data from or to the backend database and then commicates back to Active Controller
  5. Active View (View) show the presentation and communicates with Active Controller. Interface shows the related rhtml or rxml and interacts with the user

Diagram-32 - flow-chat showing the steps of MVC approach from CSU notes (Source: eNode Inc, 2002 - http://www.enode.com/x/markup/tutorial/mvc.html)


Reference:

1. TutorialsPoint (2009). "Ruby on Rails MVC Framework". Tutorials Point - A Self Learning Centre, Retrieved from URL - http://www.tutorialspoint.com/ruby-on-rails/rails-framework.htm


No comments:

Post a Comment