Friday, April 10, 2009

Elevator Pitch

This is our elevator pitch for this assignment.

Monday, April 6, 2009

Workshop 4

TO Do List for 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/

On this tutorial, you can learn basic to advanced programming techniques on ruby. Besides that, you will learn quite efficient tips on ruby programming language.

This tutorial covers following important topics;

1. Getting input from user
2. Learning how is a function called by another function
3. Basic syntax structure and default functions in ruby such as, upcase, puts...etc.
4. Adding methods to existing library classes.
5. Variable naming. For example meanings of $, @@, @, ?, !, #, \, __END__, and so on...
6. Object oriented programming techniques
7. Data structures
8. Control statements, such as if, when, while...
9. Regular expressions which are surrounded by "//" or "%r{}".
10. File input/output methods
11. Miscellanous Commands
12. Using of REPL (Read, Eval, Print, Loop)
13. Ruby on Rails properties
14. Watir GUI usage
15. How to use Watir with NUnit

After this tutorial, we can say that ruby is a fourth generation language like JAVA. It provides many easy ways to develop an application.

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

If statement synatx for Javascript;

if (condition1)
{
code to be executed if condition1 is true
}
else if (condition2)
{
code to be executed if condition2 is true
}
else
{
code to be executed if condition1 and
condition2 are not true
}


If statement syntax for Ruby

if condition1
code to be executed if condition1 is true

elseif condition2
code to be executed if condition2 is true

else
code to be executed if condition1 and
condition2 are not true

end

As it can be seen from above descriptions, Ruby is a very clean and readable programming language. Unlike Javascript, it is not needed with curly brackets and space between else and if key words or hard to understand method names. But in order to specify end of the if statement block, you need to write "end" under the last condition in Ruby.


3) While Ruby and Python are quite similar, can you find some similarities between Ruby and Javascript?

1. Perl and Python provide unlimited extent for variables captured in closures, but Ruby and Javascript do not.
2. Both of them are object oriented languages. So, they need same programming knowledge.
3. In javascript, any function can be passed as a parameter like in ruby.
4. In both languages, an object without functions can use another object's functions if they are exist. (Scott, 2006, p. 724)

References

Scott, M.L. (2006). Programming language pragmatics (2nd ed.). Morgan Kaufmann Press



Challenge Problems

1. Create, test and debug a Ruby program called dognames.rb or catnames.rb to accept 3 names from the keyboard and to display each name on the screen in alphabetical order WITHOUT using a data structure such as a list.

You can see catnames.rb code and its' executed result below windows;






2. Write a Ruby program called fizzbuzz.rb that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".


You can see fizzbuzz.rb code and its' executed result below windows;








3. Compare the Ruby and Python versions of the dog years calculator:

#!/usr/bin/ruby
# The Dog year calculator program called dogyears.rb

def dogyears
# get the original age
puts “Enter your age (in human years): "
age = gets # gets is a method for input from keyboard
puts # is a method or operator for screen output

#do some range checking, then print result
if age <> 110
puts "Frankly, I don't believe you."
else
puts "That's", age*7, "in dog years."
end
dogyears

Python

#!/usr/bin/python
# The Dog year calculator program called dogyears.py

def dogyears():
# get the original age
age = input("Enter your age (in human years): ")
print # print a blank line

# do some range checking, then print result
if age <> 110:
print "Frankly, I don't believe you."
else:
print "That's", age*7, "in dog years."

### pause for Return key (so window doesn't disappear)
raw_input('press Return>')

def main():
dogyears()
main()




1. In Ruby, constants begin with a capital letter, local variables with a small letter, global variables with the prefix $ and instance variables, attributes with the prefix @.
2. Method definition styles differ from each other. Ruby does not uses bracklets but Python does.
3. Read and write commands also differ from each other.
4. In Ruby, there is a "pause command" but Python does not use.
5. Ruby's condition statements are different from Python's condition statements. For example, in ruby; "elseif" and "end" key words are used. In Python, just uses "elif" key word.

Workshop 3

To Do List for Workshop 3

1) Set up the MySQL tools on your computer from the below link.
http://dev.mysql.com/downloads/gui-tools/5.0.html

After download progress is completed, you will need to open your Windows Vista Firewall to permit MySQL connections to the MySQL server port (3306). To do so, open Control Panel again, and select the Allow a program through Windows Firewall option of the Security group.




Finally, you can start installing MySQL. Double-click the Windows Essentials MySQL setup program to get started:



Select the default (“Typical”) settings and location and let the program install itself.



After, installation and configuration processes, you still need the Ruby on Rails gems. Install them with the command "C:\> gem install rails capistrano mongrel mongrel_cluster".
The MySQL adapter gem needs to be installed next. "C:\> gem install mysql"
Once the command completes, you should be able to use ruby on MySql database.


2) Rails will setup a new application directory for each of your Web application projects. Get InstantRails (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).

As it is introduced on workshop 2, I prefered to get InstantRails because of my computer's operating system. We can see its file system and content on below window.





3) 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.

On this project, I am going to use sqlite3 database system. So, I need to specify, it's configuration requrements.


4) Generate the Passenger model by creating the MySQL database.

Now, we need to create required table for our application. Command by "ruby script/generate scaffold origin name:string contact_no:integer suburb:string street:string street_no:integer building:integer"

After this process, you have to command "rake db:migrate" to create MVC based files.



After these two commands, table is cretated on sqlite3 database and other required files for model, view and controller directories are created as well. So, we need to restart web server with mongrel.

Then, open a web browser and type "http://localhost:3000/origins"








Now, we have two separate tables and their belongings with MVC files. After that point, we need to create an association between destination which is shown on workshop 2 and origin. So, associations allow abjects to interact.
Associations are methods that map the primary keys of one table to the foreign keys of another; the relational mapping part of “object-relational mapping”.

Open app/models/destination.rb and modify its contents with the following window:


Key word is on this screen is belongs_to :origin. The belongs_to method provides association with another table that we wish to associate. And this table (destinations) has a foreign key column called origin_id that will reference the id column in the origins table.

After all association processes are completed, final screens will be like below.







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

David Mertz, on this article, gives brief explanation about Ruby on Rails and its fundamental structure on MVC. In other words, it mentions that benefits of Ruby on Rails to the developers and how it uses MVC design pattern. These two main topicis were introduced in previous workshops. Moreover, on this article emphasize that code generation processes and creating an association between two different tables for a same application. Code genaration processes include generating the scaffold model and controller, and customize the view for user expectations. Besides that, all of them is working on MySql database, so he mentions how does ruby on rails work on MySql databese. Consequently, this article is quite useful to have strong knowledge on Ruby on Rails and MySql for beginners.

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

Rolling with Ruby on Rails article is a kind of user manual for beginners, because it mentions from installations processes to your first application's coding requirements, step by step. These are;

1. Ruby installation

2. MySql & MySql Front installation

3. Cookbook web application basic file creation.

4. Table and fields creation on MySql database.

5. Creating an association between a recipe and category tables

6. Summary

On this article, although, versions of Ruby and MySql are not latest ones, it is quite useful for beginners to understand what they need to start to learn ruby.


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.







Thursday, April 2, 2009

Study Guide Exercise 11

1. Conduct research on the Internet to find out what tools can be used to parse an XML document and ensure that the document is well formed and valid.

From the research that we conducted we were able to find 2 XML parser tool. The first one is built on C language. It is called the Expat, which is an XML parser library written in C. It is a stream-oriented parser in which an application registers handlers for things the parser might find in the XML document (like start tags). An introductory article on using Expat is available on xml.com. The second one is built on C++, it still does not have an official name yet. It prides itself in the small size which is only 104 Kb.

Reference:
C++ XML Parser (2008), Last Accessed April 7th, 2009 from
http://www.applied-mathematics.net/tools/xmlParser.html

The Expat XML Parser
(2007), Last Accessed April 7th, 2009 from
http://expat.sourceforge.net/


2. XML schema is a forthcoming development of the technology. Visit the
W3C website and search for information on schema. What are the benefits
of adopting a schema standardized for a business sector?

XML Schema
XML Schemas express shared vocabularies and allow machines to carry out rules made by people. They provide a means for defining the structure, content and semantics of XML documents. The benefits of adopting a standarized schema is that when doing integration with other organization, with the same schema all the system that is being integrated can communicate easily even though they all uses a different program.


Reference:
XML Schema (2008), Last Accessed April 7th, 2009 from
http://www.w3.org/XML/Schema

3. What are DOMs and why were they developed?
The Document Object Model (DOM) is a platform- and language-independent standard object model for representing HTML or XML documents as well as an Application Programming Interface (API) for querying, traversing and manipulating such documents. DOM was developed to enable different system to be able to manage different HTML and/or XML documents which also have diffferent standards.


Reference:
Document Object Model (2008), Last Accessed April 7th, 2009 from
http://en.wikipedia.org/wiki/Document_Object_Model

4. Why are some developers using SAX instead of DOM for document
processing?


Unlike DOM, SAX have no formal specifications. The Java implementation is considered to be normative, and other languages implementations attempt to follow the rules that is being used in that implementation .
SAX parsers have certain benefits over DOM parsers. The memory needed for SAX to perform its functions is much smaller than that of DOM. This is because DOM parsers must have the entire inout data in memory before any processing can begin.By contrast, SAX memory usage is based only on the maximum depth of the XML file (the maximum depth of the XML tree) and the maximum data stored in XML attributes on a single XML element. Because both of these are always smaller than the size of the whole input data itself, SAX memory usage is always smaller.
Another advantage is that SAX document processing time is often faster than that of DOM. Due to the nature of DOM, streamed reading from disk is also impossible. Processing XML documents that could never fit into memory is only possible through the use of a stream XML parser, such as a SAX parser. Or a swap file.


Reference:
Simple API for XML (2008), Last Accessed April 7th, 2009 from
http://en.wikipedia.org/wiki/Simple_API_for_XML

5. SMIL is an application of XML. What is the purpose of this technology?
Where does it apply?

SMIL the Synchronized Multimedia Integration Language, is a W3C recommended XML markup language for describing multimedia presentations. It defines markup for timing, layout, animations, visual transitions, and media embedding, among other things. SMIL allows the presentation of media items such as text, images, video, and audio, as well as links to other SMIL presentations, and files from multiple web servers. SMIL markup is written in XML, and has similarities to HTML.
The purpose of SMIL is to handle Multimedia files in a web page better. It is very useful in a heavily loaded multimedia content webpage, because of all its functions, it enables developer to better manage a web page multimedia contents.


Reference:
Snychronized Multimedia Integration Language (2008), Last Accessed April 7th, 2009 from
http://en.wikipedia.org/wiki/Synchronized_Multimedia_Integration_Language

6. The current recommendation of W3C is to use XHTML as an alternative to HTML.

The Extensible Hypertext Markup Language, or XHTML, is a markup language that has the same depth of expression as HTML, but also conforms to XML syntax.
While HTML prior to HTML 5 was the application of Standard Generalized Markup Language (SGML), a very flexible markup language, XHTML is an application of XML, a more restrictive subset of SGML. Because they need to be well-formed, true XHTML documents allow for automated processing to be performed using standard XML tools—unlike HTML, which requires a relatively complex, lenient, and generally custom parser. XHTML can be thought of as the intersection of HTML and XML in many respects, since it is a reformulation of HTML in XML.


Reference:
Extensible Hypertext Markup Language (2008), Last Accessed April 7th, 2009 from
http://en.wikipedia.org/wiki/XHTML

7. Do you think adopting XHTML is a wise move?

At the current time, we do not think that adopting XHTML is a wise move. The lack of standard and support for XHTML means that they are still not a globally used language. As mention that even IE6 does not support XHTML. So it is clear that the use of XHTML, even though it is a better language than standard HTML, there is no use in adopting it if people still have problems accessing it.

Reference:
Extensible Hypertext Markup Language (2008), Last Accessed April 7th, 2009 from
http://en.wikipedia.org/wiki/XHTML

Study Guide Exercise 11

1. Conduct research on the Internet to find out what tools can be used to parse an XML document and ensure that the document is well formed and valid.

From the research that we conducted we were able to find 2 XML parser tool. The first one is built on C language. It is called the Expat, which is an XML parser library written in C. It is a stream-oriented parser in which an application registers handlers for things the parser might find in the XML document (like start tags). An introductory article on using Expat is available on xml.com. The second one is built on C++, it still does not have an official name yet. It prides itself in the small size which is only 104 Kb.

Reference:
http://www.applied-mathematics.net/tools/xmlParser.html
http://expat.sourceforge.net/


2. XML schema is a forthcoming development of the technology. Visit the
W3C website and search for information on schema. What are the benefits
of adopting a schema standardized for a business sector?

XML Schema
XML Schemas express shared vocabularies and allow machines to carry out rules made by people. They provide a means for defining the structure, content and semantics of XML documents. The benefits of adopting a standarized schema is that when doing integration with other organization, with the same schema all the system that is being integrated can communicate easily even though they all uses a different program.

Reference:
http://www.w3.org/XML/Schema

3. What are DOMs and why were they developed?
The Document Object Model (DOM) is a platform- and language-independent standard object model for representing HTML or XML documents as well as an Application Programming Interface (API) for querying, traversing and manipulating such documents. DOM was developed to enable different system to be able to manage different HTML and/or XML documents which also have diffferent standards.

Reference:
http://en.wikipedia.org/wiki/Document_Object_Model

4. Why are some developers using SAX instead of DOM for document
processing?

Unlike DOM, SAX have no formal specifications. The Java implementation is considered to be normative, and other languages implementations attempt to follow the rules that is being used in that implementation .
SAX parsers have certain benefits over DOM parsers. The memory needed for SAX to perform its functions is much smaller than that of DOM. This is because DOM parsers must have the entire inout data in memory before any processing can begin.By contrast, SAX memory usage is based only on the maximum depth of the XML file (the maximum depth of the XML tree) and the maximum data stored in XML attributes on a single XML element. Because both of these are always smaller than the size of the whole input data itself, SAX memory usage is always smaller.
Another advantage is that SAX document processing time is often faster than that of DOM. Due to the nature of DOM, streamed reading from disk is also impossible. Processing XML documents that could never fit into memory is only possible through the use of a stream XML parser, such as a SAX parser. Or a swap file.

Reference:
http://en.wikipedia.org/wiki/Simple_API_for_XML

5. SMIL is an application of XML. What is the purpose of this technology?
Where does it apply?

SMIL the Synchronized Multimedia Integration Language, is a W3C recommended XML markup language for describing multimedia presentations. It defines markup for timing, layout, animations, visual transitions, and media embedding, among other things. SMIL allows the presentation of media items such as text, images, video, and audio, as well as links to other SMIL presentations, and files from multiple web servers. SMIL markup is written in XML, and has similarities to HTML.
The purpose of SMIL is to handle Multimedia files in a web page better. It is very useful in a heavily loaded multimedia content webpage, because of all its functions, it enables developer to better manage a web page multimedia contents.

Reference:
http://en.wikipedia.org/wiki/Synchronized_Multimedia_Integration_Language

6. The current recommendation of W3C is to use XHTML as an alternative to HTML.

The Extensible Hypertext Markup Language, or XHTML, is a markup language that has the same depth of expression as HTML, but also conforms to XML syntax.
While HTML prior to HTML 5 was the application of Standard Generalized Markup Language (SGML), a very flexible markup language, XHTML is an application of XML, a more restrictive subset of SGML. Because they need to be well-formed, true XHTML documents allow for automated processing to be performed using standard XML tools—unlike HTML, which requires a relatively complex, lenient, and generally custom parser. XHTML can be thought of as the intersection of HTML and XML in many respects, since it is a reformulation of HTML in XML.

Reference:
http://en.wikipedia.org/wiki/XHTML

7. Do you think adopting XHTML is a wise move?

At the current time, we do not think that adopting XHTML is a wise move. The lack of standard and support for XHTML means that they are still not a globally used language. As mention that even IE6 does not support XHTML. So it is clear that the use of XHTML, even though it is a better language than standard HTML, there is no use in adopting it if people still have problems accessing it.

Reference:
http://en.wikipedia.org/wiki/XHTML