Sunday, April 5, 2009

Workshop 2

Question 1) Setup a focus group to work on the Ruby on Rails workshop via interact tools as a class.

In order to provide connection between students and subject lecturer Mr. Peter Dalmaris, focus group has been set up by Mr. Dalmaris. By the way, all students can interact with each other, while they are working on Ruby on Rails workshops. In order to establish a group platform, GoogleGroups are used and it's name is ITC594. Through this group, all members can discuss on Ruby on Rails related problems and their solutions. Please visit our group page, to see other details.

http://groups.google.com/group/itc594?hl=en



Question 2) What is meant by “convention over configuration” and how does it reduce coding?

It is an idea that has become very popular in the past few years with frameworks like Ruby on Rails, which allow you to write very complex web applications without hacking at a huge number of coufiguration files. (Elliott, O'Brien, & Fowler, 2008, p. 240)
In other words this idea provides software development without having to specify any configurations and use development routines. Ruby on Rails infrastructre does otomatically generate these routines and configurations instead of developer. Therefore, you just need to use predefined development rules. Because, Rails is able to figure out which classes and methods handle every page request, simply by inspecting the URL. The name of controller class, an action method, and a primary key identifying a record being worked with specified in the URL. (Fisher, 2008, p. 69)

References

Elliott, J., O'Brien, T., & Fowler, R. (2008). Harnessing Hibernate. O'Reilly Press
Fisher, T. (2008). Ruby on Rails Bible. John Wiley and Sons Press


Question 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


a) The topic is no longer exist.

b) I can summarize the MVC tutorial from the above link as The Model-View-Controller or MVC design pattern is taken from Smalltalk-80, which is a classic standard ClassBuilder language. It has long been accepted as a better way to architect software applications MVC is accepted as a better way because it makes applications easier to develop, understand, and maintain. Mvc simplifies the implementation of an application by dividing it into several layers, each with a given role and responsibilities. (Smalltalk-80, 2006)
MVC was originally created with desktop GUI applications in mind. When developers first started writing web applications, they took a step backward and seemed to have forgotten the benefits of MVC. Many of the early web applications mixed business logic, presentation, data access, and event handling all in gaint, complex script files written in Languages such as PHP. Perl, and Java's JSP. (Fisher, 2008, p. 70)

References

Fisher, T. (2008). Ruby on Rails Bible. John Wiley and Sons Press
Smalltalk-80. (2006). Retrieved March 10, 2009, from http://wiki.squeak.org/squeak/373


Question 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

This video clip covers just the first topic of the followings;

1) Web apps, MVC, SQL, Hello World
2) Ruby and basic Rails
3) Advanced model relations
4) AJAX & intro to testing
5) Configure & deploy

As it can be understood from the content, requirements of web applications are mentioned and the most fundamental topic was about MVC understanding. For example, how it works and how it interacts with other objects. Moreover, it mentions that goal of the MVC approach, such as to separte organization of data (model) from UI & presentation (view) by introducing controller. Then, it tells about SQL table structure and relation between web application and data base.
Another significant part of the tutorial is about, the CRUD (Create, Read, Update, Destroy) operations on model, scaffolding and migration techniques of Ruby on Rails. Besides that, Convention over configuration idea is also quite important thing for ruby on rails infrastructre.
Finally, definitions of "Ruby" and "Rails" terms and ruby's file structure are mentioned to emphisized the importance of models relations. Therefore, after all of these simplified explanations, benefits of the ruby on rails and its basic understandings are more clear for me.

Question 5) 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

According to documentation of The Model-View-Controller Design Pattern by Colin Moock, using with MVC pattern, we are able to separate the Model (the class that holds the data of the application), the view (the visual presentation of the application), and the Controller (the class that handles user interaction). But, besides that, the most significant thing is the how model, view and controller interact with each other. In addition to this, it mentions that The Observer pattern. It provides the basic services for the model-view relationship. (Add, remove, show, update)

Model: Implements the Observer pattern and sends notifications to the view when there are changes in data.
View: Holds a reference to the Model and the Controller, and it can only connect to the Model to retrieve information when it receives request from the Model. When user call a view method, the view calls the appropriate method on the Controller.
Controller: Holds a reference to the Model and updates that Model through the methods that are called from the View.

This above knowledge is about general architecture of MVC. On the other hand, as it is shown on MVC clock applicaion, ActionScript is a visual implementation of OOP techniques. Moreover, it has same class structure as MVC. This allows developers to work on an application together more easily and efficiently.


Challenge Problems

1) How is Rails structured to follow the MVC pattern?
2) Apply the MVC design approach to our Project: Online Taxi Booking System.

In this part of the workshop, I am going to show you how can a MVC pattern be constructed on Rails framework. So we need to create a sample application to introduce details and online taxi booking system will be a good example for it. On this project, there will be two tables to hold user data and instant rails will be quite enough to complete the requirements.

First of all, we need to construct application file structure based on MVC pattern.

1. Open a command prompt and go to C:\InstantRails-2.0-win\rails_apps


2. Command "rails taxi" and you will see that it will create all required file structrure like below



3. Then, you need to enter the "taxi" directory by "cd taxi" command.


4. Create the taxi sqlite3 database by " rake db:create RAILS_ENV='development' " command. Then to make sure our aplication can talk to the database command "rake db:migrate".

5. Now, we need to create required tables for our application. Before, we start this process, we need to think about required fields and their types. Then, command "ruby script/generate scaffold destination suburb:string no_of_passengers:integer taxi_type:string time_required:time origin_id:integer"




6. After this process, you have to command "rake db:migrate" to create rails created all files according to MVC pattern that provides show, index, new and remove properties as shown below window.







1 comment: