Monday, June 1, 2009

INTRODUCTION II (Asignment 2)

As a continuation of our work through the subject, a new series of workshops had been developed. After the first four workshops we had created an Online Taxi Booking System (OTBS) using Ruby on Rails as a framework to develop the application utilizing MVC architecture. This second series of workshops (5 to 8) will conduces us to further work and improvement of the OTBS application. However as part of the task our group must be divided either a Developer or an IT Infrastructure Manager. As well as the entire course, hence, we will have approximately half of the students as a Developer and half as a Manager, forming Red and Blue teams respectively.
As we advance in our work, we will be posting workshops solutions according to the chosen role. The main goal is not only solve the workshop, it is also the capability to work as a team and be able to share and support the different perspectives that a developer and an IT Infrastructure Manager have.
The specific roles given to each role are the following, where my friend Chul will be developer and, Gaurav and I will assume an IT Infrastructure Managers' role.

For Developers Thread: (Red Team)
· To create a Rails application framework with the WEBbrick or Mongrel Web server and:
o Generate a controller and an action by adding a method(s) to a controller.
o Create a view template for each action and to link to action from views
o Use rails to build applications with document request, screen layouts and forms processing
· To share your findings with others

For IT Infrastructure Managers: (Blue Team)
· To examine and analyse what the developers are doing in their thread
· To investigate ideas for enhancing customer experience though use Web 2.0 and mobile devices technologies
· To determining what IT infrastructure such as hardware, networking, software, systems, procedures and personnel would be needed to support Developers if they were asked to provide mobile device interfaces to the OTBS in a stage 2 projectTo develop and share a simple business process model for an improved taxi customer experience through use of technology.

Friday, April 10, 2009

PODCAST

In the podcast I have posted video file which gives blog viewers quick information about our blog. By clicking on the video’s play button you can hear quick information about blog.

Tuesday, April 7, 2009

TUTORIAL 1

On this class tutorial we are doing a simple application containing a couple of web pages.
- Create the application named “MyApp” → rails MyApp
- Go into the application folder → ruby script/generate controller say
- Go to the Say folder (rails_apps/MyApp/app/view/say) and create two files using a text sheet and name them as “hello.html.erb” and “goodbye.html.erb”.
- Write into the files as follow using hello. For the goodbye file just replace “hello” by “goodbye”:


- This commands creates a hello/goodbye sentences, next line it would show the date and time, follow by a link to the goodbye/hello page.
- Next step is to define the variables used into the controller: Go to(rails_apps/MyApp/app/controller) and open with the “word pad” the file “say_controller”. And modify to make it like follows:

class SayController <>
def hello
@time = Time.now
end

def goodbye
@time = Time.now
end
end

- Now is ready to run it → ruby script/server (to start the server)
- Open a web browser and type → http://localhost:3000/say/hello



- Click on the link “Goodbye”


That’s it, your first ruby page application.

WORKSHOP 4

1. Spend some time moving your way through the 46 Ruby coding examples in the Ruby Tutorial with Code from http://www.fincher.org/tips/Languages/Ruby/

Done


2. What are the syntax differences in the way that Ruby and Javascript use the if statement?

Using if statement, javascript has the ability to make distinctions between different possibilities. For example, you might have a script that checks if Boolean value is true or false, if variable contains number or string value, if an object is empty or populated, or even check type and version of the visitors browser (“JavaScript If statement” n.d.).
An if statement in Ruby is pretty similar to “if” statements in other languages. If you lay out your if statements on multiple lines, you can leave off the then keyword. However, if you lay your code out more tightly, the then keyword is necessary to separate the Boolean expression. May have zero or more elsif clauses and an optional else clause.
3.While Ruby and Python are quite similar, can you find some similarities between Ruby and Javascript?
JavaScript has many of the same language features Ruby has, includingextension by mixin, duck typing, a YAML equivalent (JSON), arbitrary classand object extension (i.e. adding methods/properties to classes or specificobjects at any time), simple arrays and hashes, etc.
It also hasfirst-class functions, which are equivalent (though not identical) toblock (FAQ and JavaScript vs. Ruby, n.d.)


Reference
ASP Net Center, Retrieved March 31,2009, from ://www.aspnetcenter.com/cliktoprogram/javascript/ifstatement.asp
FAQ and JavaScript vs. Ruby (was Re: rubynuby - client side Ruby?), Retrieved March 30, 2009, from http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.ruby/2006-02/msg02949.html
Programming Ruby The Pragmatic Programmer’s Guide, Retrieved March 31,2009, from http://www.rubycentral.com/pickaxe/tut_expressions.html

WORKSHOP 3

Question1. Set up the MySQL tools on your computer as described in section 6 above.
ANS
When I have installed RUBY on rails on my laptop I have set up MySQl along with Ruby and Rails installation which shows on our blog under the name Installation of Ruby on Rails part.

Question2. Rails will setup a new application directory for each of your Web application projects. Get Instant Rails (Windows) or Locomotive (MacOS) running on your machine. Both packages install Ruby, Rails, a Web server or one called ‘Mongrel’ or another small Ruby Web server called ‘WEBrick’, and MySQL “inside a bubble” as I call it so that others parts of your system are not modified (Similarly ZOPE does with installing its own Web server and Python versions).

ANS:
This task also has been done on this blog and it is also under the same Installation of Ruby on Rails part on our blog.

Question3. Once Rails is running you at http://localhost:3000, you need to configure database access. Connection to the database is specified in the config/database.yml file.

ANS:
Actually when we create any model in Ruby on Rails it is possible to access a file named database.yml under folder named config, and that screen shot is given below and we can configure the database access by using that file.



Question4. Generate the Passenger model by creating the MySQL database and ‘passengers’ table from the information above.

ANS:

In this section we will create a table named passenger1 in which we will create some fields and it will work like a Taxi Booking Service centre in which customer can book the taxi service for their traveling. This table will have various different fields like Name, Destination Address, Origin Address, Time, Date and the like. We will have a better look on the screen shots which I have taken during the creation of this table by using Ruby over Rails with the description, so that everything should get clear that how it works and how it represents the final page regarding the taxi booking information. Screen shots related to the creation of this table is given below.







Above screen shot shows I have used Rails command to create taxi application and process of this system.

In the above screen you can see I have used three commands first needs to be created a scaffold in which I created model named passenger1having different attributes like name, contact no, destination – origin address etc. after that to check models I used by command named rake db: migrate to check whether my application is talking to database or not and then after that I run the server using command named ruby script/server to run my applications.




The above screenshot shows that the model is running properly and we are on the right track for the taxi booking system


In the above screen shot shows tat the filling of different attributes by the operator in order to book the taxi for my self.

The above given screen shot displays the successful creation of fields entered by me related to customer’s journey as an example.


The above screen shot shows the successful creation of taxi booking model named passenger2 and is ready to enter the details of other passenger.

Question5. Further work on understanding MySQL under Rails by David Mertz:a. See “Fast-track your Web apps with Ruby on Rails” at http://www-128.ibm.com/developerworks/linux/library/l-rubyrails/
ANS:
As asked in the above question I followed the given link in the question. I have found some very useful information for the ruby on rails along with the really good information of description of role of model, view and controller on it. This link also gives quick and good understanding of coding in the environment of ruby on rails. It is very helpful to understanding the exercises and workshops. This link is very useful to understand the ruby and rails for the new learns with ruby and rails.

b. The “Rolling with Ruby on Rails” series and “Cookbook recipes by Curt Hibbs and others beginning at http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html
ANS:
The link by Curt Hibbs is very useful to understand the topic on the Ruby and Rails it shows that how to install ruby and rails from introduction t the installation of ruby on rails in our system along with the MySQL installation which help me a lot to making this assignment and learning ruby and rails quite good as a new learner.
















WORKSHOP 2


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

To work on the workshops using Ruby on Rails we had setup a forum group where we can discuss end help each other. For this forum, a group was created in Google, tool known as GoogleGroups. The group’s name is “ITC594” where all students are expect to participate helping each other, please visit
http://groups.google.com.au/group/itc594?hl=en.

Screenshot of the course’s Google Group.


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

Convention over Configuration (CoC) is considered for many experts the new and optimum way of developing web applications. And as mentioned in the previous workshop, there are a lot of things to consider developing web applications, and one of them is structuring things. It is well known that all these web applications have a lot in common, so many time is spend doing things over and over again.

Convention means that developing on Rails its only necessary to consider non-conventional features of the application due “it is built around a set of opinions about how to build web applications”. This leads to minimize the developers time reducing the configuration code and less repetition.


3. Further work on understanding MVC:
a. See the wiki at
http://wiki.rubyonrails.org/rails/pages/UnderstandingMVC
A message is displayed “This topic does not exist yet”.


b. Do the MVC tutorial at
http://wiki.squeak.org/squeak/1767

This is a good tutorial to understand from the origins of the MVC.
The Model View Controller was developed by Trygve Reenskaug in 1979, and important to mention that this was before the concept of design pattern. It is considered one of the most successful and earliest design approaches. The author emphasises that MVC was the pattern behind Smalltalk-80, which interface with overlapping windows was latter used by Macintosh and Windows.

The model have been so successful that is still used for developing new frameworks interfaces, for instance Java Swing and Ruby on Rails.

4. Got a spare hour or so? I recomended the UC Berkeley RD lab’s Ruby on Rails Short course at
http://youtube.com/watch?v=LADHwoN2LMM

This is a great video, worth so see it. Even if is quite long it will help you to understand Ruby on Rails pretty much from the beginning.

There are a lot of content and I will not going specifically through of them, because you have to see it.

The video starts with a simple and clear introduction about Webs applications, RPC protocol = HTTP, and how it works in a short “one slide resume”. He talks first about frameworks and its common structures, to start speaking about Ruby on Rails. After the general idea he gives some easy examples (“hello world”). Then he shows how Ruby on Rails works with an MVC approach and explains it well. Then with this content, he speaks about SQL and the design of tables using the mentioned approach with some examples (you can see similar examples executed later on this workshop or in the next one). Finally he closes the video emphasising Rail’s “convention over configuration” which we already explained in previous questions.

So if you have not much idea about Ruby on Rails, this video is an excellent way to start understanding Ruby and its environment.


5. Read the Flash article using ActionScript by Colin Moock tittled “The Model-View_Controler Design Pattern” at http://www.adobe.com/devnet/flash/articles/mv_controller.html

Once again the article’s main topic is MVC. Is a pretty good one do, and its going a bit deeper defining MVC. It explains the beginnings of MVC paradigm as in the question 3 article.


It well defines the three classes: Model, View, Control, as defined in workshop one. However, even we already read about same topic is always good have different approach and different examples to reach a better understanding.

Challenge problems - Workshop 2
In this part of the second workshop we will be using some Ruby on Rails applications to work in our project called “Online Taxi Booking System”. Where we will be using database design techniques and the MVC design approach.
The database has two tables: passenger_origin and passenger_destination, where into each of them, some fields have been created and defined to describe the table, like name, addresses, contact numbers, etc.
There are several steps we have to follow, and to make it clearer some screenshots will be pasted for easy understanding.

· The first step is to create the application, just typing >Rails (and the name of the application) in our case “taxi”, as shown in the following screen shot:
· Then we create the taxi sqlite3 database and migrate it, to check if the application is talking to the database.

· After that we need to create the scaffold for both passenger_origin and passenger_destination with all the data to describe our tables. Using the command to generate scaffold as shown in the screenshot:



· Finally, to create the table in the database we need to apply the migration file as follows:


· Now run the server and open your browser on http://localhost:3000/passenger_origins

You should see something like this:




· If you click on the link for a new passenger the following page shoul show up:



· Important to validate the data, this is for example, defining a value as a number or non blank space, so if in that field is required to entry a value, and is not entry, an error message should display:


· Once the information is entry properly and create this page is to be seen:



· Finally back to the main page to see the register created.







For the passenger destination the same steps are to be used.


So the application is done and working properly, and the best, it does not take much time, right?
So important to practice some new application or practice modifying the databases or any other function. The important think is understand the logic behind and learn to read the files that rails create. There are plenty of useful tutorials to go further for use Rails.

References:
Building web applications (n.d). Ruby Lessons podcasts. Retrieved March 20, 2009, from http://www.buildingwebapps.com/podcasts

Wikipedia. The free Encyclopaedia. Retrieved March 28, 2009 from http://en.wikipedia.org/





























WORKSHOP 1

LEARN RUBY AND RUBY ON RAILS

The first thing to do is understand the tool we are going to be using. Ruby on Rails is considered today as the hottest technology in web application development. A really good way to introduce you to this technology is visiting the web page: http://www.buildingwebapps.com/podcasts, in this page you will find a series of Audio Lessons and Screencasts that clearly explain what it is “Ruby” and “Rails” technologies. You also can subscribe yourself by writing your name and e- mail to receive periodically the podcasts that will introduce you to Ruby. (See picture bellow)

Screenshot: Subscribing for Ruby audio lessons



INSTALL RUBY AND RUBY ON RAILS

After an understanding what is Ruby and what it is for, the second step is installing Ruby and Rails in your computer as I’ll show you:

1. Get into the web page
http://rubyonrails.org/download and click on Windows Installer (if you are a Windows user) as shown in the figure. Then download and install the latest version clicking on the executable application.


2. Run the setup and follow Instructions until installation is finished as shown in pictures.




3. Once Ruby is Installed, download and Install RubyGems which install Rails and its dependencies through the command line. You can also find the latest version from http://rubyonrails.org/download.

4. Finally run “RubyGems Package Manager” from your program list and type in the command line “gem install rails” to install rails. (See screenshot bellow).



And that’s it, you Ruby on Rails is installed and ready to go.Any inquiry or problem installing the application just let us know and we’ll try to help you out.

INSTALLING INSTANT RAILS (For Windows)
For Windows users, you can also install directly "InstantRails". This package contains Ruby and Rails, so I personally recommend to install InstantRails rather than everything separately.Just follow this link, get the latest version, and better download it first to your computer.http://rubyforge.org/frs/?group_id=307


You can unzip the file direct on the previously created ruby folder on "C:".
Unzipping and installation it's going to take a while. The process took me about 10 minutes and 15 to my friend's, I thought the computer got stock but it's just matter of time, so, be patient.


To run InstantRails, go to the folder where you extract the files and find the executable file (an icon with a big "I"). Then you should see this screen.



INSTALLING LOCOMOTIVE (For OS X users)

How to install ruby on Mac OS X Leopard?

In Leopard and Leopard Server, Ruby and Rails are pre-installed along with a bounty of other useful RubyGems. This means we can hit the ground running when it comes to developing a Rails application and keep up the pace when deploying new releases of our application to Leopard Server.

Out of the box, you get Ruby version 1.8.6 and Rails version 1.2.6, the latest stable releases at the time Leopard shipped.
TRY SOME RUBY
Use mac terminal to try first simple ruby program " hello world"
find and open terminal, and try:
~ zc$ irb***
>> print "hello world\n"
Hello world
=>nil
use Math lab.

UPDATE NEWEST RUBY ON MAC X

Ruby in mac is buildin, however how can we get newest one?Just by using some simple command (you need connect to internet)in Terminal window:

sudo gem update --system
sudo gem install rails
sudo gem update rake
sudo gem update sqlite3-ruby
Now you can get newest ruby version!, and same time please install xcode or textmate.
Textmate is not free so, if pople don't like pay money and even take care about copyright please use Xcode 100% free download from apple web.
Install if as install normal software.


Challenge Problems - Workshop 1


1. Make a list of all programming languages and Web development tools used by you in prior experiences. Describe what you know about Web application frameworks

There are several programming languages at these days I started many years ago using PASCAL, later I learned C++ and Visual Basic, each time the languages are getting simpler and with more applications, but normally following the same programming logic “object-oriented”. Particularly the last one allows me to easily create XML files using some applications, where this information was shared on the net using Web Services. Furthermore Ruby is also an object-oriented programming language but relatively newer, Ruby is has been getting even more popular due to “Ruby on Rails” or just Rails which is a web application framework that using a fast methodology has reduce considerably the time developers spend developing websites or Web applications.


2. Ruby is “an interpreted scripting language” for quick and easy object-oriented programming”. Find out about the Ruby language and discover what this means.

Ruby was designed by Yukishiro Matsumoto on 1990, it is considered as “the hottest technology for web applications” (Slater, M.). Inspired on Pearl and Python, Ruby is defined as an object-oriented language, because like any other object-oriented language an object encapsulate some data and the actions to be taken on these data, then your program is build based on this “capsules”. Ruby it is also an interpreted scripting language due is interpreted dynamically when the program is been executed, hence, not compilation required.


3. What is Rails and how does it work with Ruby?

As it was mentioned on question 1, Rails is a web application framework based on Ruby programming language. Slater (n.d.) well explained in the first podcast of Ruby on Rails saying that “an application framework such as Rails provides a structure for your code and includes a variety of powerful code modules that make many programming tasks simpler”. To organize application programming, Rails uses the MVC architecture just like many web framework, but providing metaprograming methods to build databases applications, Rails can automatically construct models and views for a simple website utilizing common tools included in the Rails framework.


4. What is meant by “convention over configuration” in regards to the use of Rails in Web application development?

So far so good, Ruby on Rails is been showing to be an excellent new way to develop web applications. However the best of Rails that I personally reckon, is that emphasise Convention over Configuration (CoC). There are a lot of things to consider developing web applications and, and one of them is structuring things. It is well known that all these web applications have a lot in common, so, many time is spend doing things over and over again.

Convention means that developing on Rails its only necessary to consider non-conventional features of the application due “it is built around a set of opinions about how to build web applications”. This leads to minimize the developers time reducing the configuration code and less repetition.


5. When did Model-View-Controller begin and where is it used?

An MVC begins when a web framework is used. In our case, for instance MVC is started when we use Ruby on Rails to develop and organize web application programming.

MVC uses its architectural pattern Model-Controller-View. Where “the Model represents the information of the application; the View corresponds to elements of the user interface such as text, checkbox items, and so forth; and the Controller manages the communication of data and the business rules used to manipulate the data to and from the model” Wikipedia (n.d)


6. Describe the steps involved with the MVC design Approach.

The way that MVC works is pretty simple. Basically there are an interface where the user is able to interact with (write a query or press a mouse button) → the controller gets the action from the user → the model controller sends to the model the event occurred on the interface → View uses the model and create an new corresponding user interface →Finally everything backs to status quo waiting for the next interaction to resume with the cycle.

The following diagram shows the relationship between Model, View and Controller. Where solid lines means direct associations, while dashed lines shows indirect associations

References:

Building web applications (n.d). Ruby Lessons podcasts. Retrieved March 20, 2009, from http://www.buildingwebapps.com/podcasts

Wikipedia. The free Encyclopaedia. Retrieved March 28, 2009 from http://en.wikipedia.org/