• Describe the history and architecture of the Model View Controller (MVC) approach to Web application design;
• Revise database techniques with Rails and SQL
• Describe how to use MVC in the Ruby on Rails development environment
• Set up a focus group (like a study group for peer learning) to work on the Ruby on Rails workshops via Interact tools
To do:
1. Set up a focus group (like a study group for peer learning) to work on the Ruby on Rails workshops via Interact tools as a class.
Focus group is setup in CSU Interact Forum where I have joined the discussion on the topics raised by other students and has looked into the problem raised by course coordinator and figure out the solution by web searching.
2. What is meant by “convention over configuration” and how does it reduce coding?
“Convention over configuration” (CoC) means a developer only needs to specify unconventional aspects of the application. For example, if there is a class Sale in the model, t he corresponding table in the database is called sales by default. It is only if one deviates from this convention, such as calling the table “product_sold”, that one needs to write code regarding these names.
When the convention implemented by the tool you are using matches your desired behavior, you enjoy the benefits without having to write configuration files. These reduce repeated coding and configuration. Only when your desired behavior deviates from the implemented convention, then you configure your desired behavior.
3. Further work on understanding MVC:
a. See the wiki at http://wiki.rubyonrails.org/rails/pages/UnderstandingMVC
b. Do the MVC tutorial at http://wiki.squeak.org/squeak/1767
Having walkthrough the wiki materials about MVC. Understood that MVC stands for Model-View-Controller and it is one of the earliest and one of the most successful design patterns. With the View rendering the graphical and textual output of the application. The Controller interprets the mouse and keyboard inputs from the user. The Model manages the behavior and data of the application, responds to requests for information about its state and responds to instructions to change state.
4. Got a spare hour or so? I recommend the UC Berkeley RAD lab’s Ruby on Rails Short course at http://youtube.com/watch?v=LADHwoN2LMM
Read the Flash article using ActionScript by Colin Moock titled “The Model-View-Controller Design Pattern “at http://www.adobe.com/devnet/flash/articles/mv_controller.html
A really long video which would take 6 hours for an undergraduate course topic on Ruby-on-Rails. It is a step-by-step approach to guide your through RoR with lab sessions. Really useful for beginners who need to have a quick introductory course and get it done within one day.
Challenge Problems:
1. How is Rails structured to follow the MVC pattern?
Consider our project and examine the directories where Rails is located. If the data model is called Taxi (it is convention to name the model beginning with an upper case letter). The model is a Ruby class located in app/models/taxi.rb
The SQL table is taxis – the pluralisation of the model. In our project we have 2 tables as passenger_origin and passenger_destination, where the table row = an object instance and each of the columns = an object attribute.
The controller methods live in app/controllers/taxi_controller.rb
Each controller can access templates to display the input screen and methods for action.
The views are kept is app/views/taxi/*.rhtml, where each *.rhtml maps to a controller method.
In Rails, the view is rendered using RHTML or RXML. According to the wiki page at http://wiki.rubyonrails.org/rails/pages/UnderstandingViews, RHTML is HTML with embedded Ruby code and RXML is Ruby-generated XML code.
The data model “Taxi” is created by issuing the following command
C:\Ruby>rails Taxi
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create test/fixtures
create test/functional
create test/integration
create test/performance
create test/unit
create vendor
create vendor/plugins
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create Rakefile
create README
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create config/database.yml
create config/routes.rb
create config/locales/en.yml
create db/seeds.rb
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/new_rails_defaults.rb
create config/initializers/session_store.rb
create config/environment.rb
create config/boot.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/console
create script/dbconsole
create script/destroy
create script/generate
create script/runner
create script/server
create script/plugin
create script/performance/benchmarker
create script/performance/profiler
create test/test_helper.rb
create test/performance/browsing_test.rb
create public/404.html
create public/422.html
create public/500.html
create public/index.html
create public/favicon.ico
create public/robots.txt
create public/images/rails.png
create public/javascripts/prototype.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create public/javascripts/controls.js
create public/javascripts/application.js
create doc/README_FOR_APP
create log/server.log
create log/production.log
create log/development.log
create log/test.log
Currently there are no views rendered and so there is no rhtml under the C:\Ruby\Taxi\app\views\taxi. Also checked the wiki link at rubyonrails.org about understanding Views is already unavailable.
2. Apply the MVC design approach to our Project: Online Taxi Booking System.
HINT: Begin with a single model, single view and single controller classes. This will give you a head start to the next workshop: Online Taxi Booking System: SQL and Database design
Model – Defines how the system handles the passengers’ data including their names, source and destination. The action is to save the data into the database and acknowledge user the data is successful save after user click the submit button.
View – Defines what the passenger would see as they access the system, input the data and submit the data.
Controller – Receives the input from the passenger and initiate the response / acknowledgement by making calls on Model which would trigger the View to render the image to acknowledge the passenger the order has been received by the system.

No comments:
Post a Comment