Friday, April 23, 2010

Elevator Pitch 1

E-systems infrastructure is just like a maze for me even I have surfing the Internet for long time.

In the last two months, I have faced a lot of new terms, models, methodologies and programming languages related to the development of the e-commerce application. We can use a wide range of development frameworks, such as JavaScript and Microsoft .Net. As Web 2.0 is become popular, AJAX on rails, Ruby on Rails and TurboGears has presenting a new architecture for rapid database application development. Through the workshops, Web 2.0 technologies and frameworks are no longer strange for me. I have tried to install and configure the Web server, MySQL database and Ruby on Rails by different tools. The model view controller approach for Web application design have demonstrated by the online taxi booking system. Moreover, I have written some codes inside the Ruby on Rails. I am sure at this moment, I am ready to continue my study journey with the developer's role.

The MP3 file can be download at the link: ftp://varianhk.servehttp.com/PUBLIC%20DISK/ITC%20594/
The file name is Elevator_Pitch_1.mp3.

Another copy is already submitted to Easts.

Tuesday, April 20, 2010

Workshop 4

Riding the Rails with Ruby

To do:


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?

Ruby if statement syntax is:
if condition
   code to be executed if condition is true
end

Javascript if statement syntax is:
if (condition)
{ code to be executed if condition is true}

It is very obvious that Ruby is lose in syntax rule than Javascript. Javascript needs to have brackets for the condition and the code,  Ruby doesn't need any brackets for condition and the code but only needs a "end" keyword to close the if statement loop.


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

First of all, Ruby and Javascript are object-oriented programming languages therefore "everyone can modify the class structure". Secondly, function can be passed as a parameter in both Ruby (code blocks) and Javascript. Thirdly, it is easy to check if an object can do something in both JavaScript (object function check) and Ruby (respond_to) (Dan, 2007)


Recommended time: 1-4 hours, but it may take several trial attempts so be patient with initial success.


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.

The required dognames ruby coding is as follow:
























This program will only accept lower case name because upper case name will always at the top of the alphabetical order. That means a mix of lower case and upper case names will produce a false result. Due to the names input from the gets command will contains a carriage return, it will affect the display result, I have use the gets.chomp command to input the names so the data will only contain the name. The output of this program will produce a very nice single line of names rather than a 3 different lines with a single name. The output is as below:













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".

The fizzbuzz.rb coding is listed below:





















I am using a "for loop" to generate the number from 1 to 100 and divide each number by 3 and 5. The program will identify what the remainder is and decide to display the number, Fizz, Buzz or FizzBuzz. In order to give a more clear result, I have added a additional condition which will start a new line after display ten numbers. Therefore, the running result shown below will be 10 lines with 10 numbers on it.














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 < 0

puts "Negative age?!? I don't think so."
elsif age < 3 or 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 < 0:
print "Negative age?!? I don't think so."
elif age < 3 or 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()


The main differences are :-

1. Python needs to have a program main body (def main ()) which ruby doesn't need.
2. Ruby uses "gets" to input the data , but python uses "input" to get the data.
3. The if loop structure is similar but the keyword has a little bit different for the case of else if. Ruby use "elsif" but python use "elif".
4.  Ruby uses "puts" to display data , python uses "print" to display data.

Monday, April 19, 2010

Workshop 3

Online Taxi Booking System: MySQL and Database design


Topic objectives

• Develop a database object design for an online taxi booking system (OTBS);
• Revise database techniques with Rails and SQL
• Describe how to use the MVC “push-based architecture” in the Ruby on Rails development environment

Topic readings

Various websites as listed.

Discussion

1. Introduction

Beginning with a single model, single view and single controller classes will assist with development of the OTBS and its SQL database design. Developed and tested on your local computer using Ruby on rails and browser before migration to the production site.

In the Rails environment, applications are developed in the MVC pattern in a DRY (Don’t Repeat Yourself) manner with a strategy of CoC (Conventions over Configuration) and the whole Rails framework gives you the locus of control plus access to class and utility libraries where the:

Model is ActiveRecord as Class ActiveRecord::Base to work SQL tables.
View is ActionView template files Class ActionView::Base
Controller is ActionController

In the previous workshop you were asked to consider the OTBS as our project vehicle for learning about Ruby on Rails as a Web application framework as well as examine the directories where Rails is located. By now you should also have looked at many online tutorials and videos about developing a simple database application with Ruby on Rails.

2. HelloWorld application in Ruby on Rails

Consider any discussion on how the Hello World application is made, as described by Armando Fox at the UC Berkeley RAD lab’s Ruby on Rails Short course at http://youtube.com/watch?v=LADHwoN2LMM.
In the Hello World application there is NO model, just a single controller called hello_controller.rb with only two controller methods and the view. Each controller method has its corresponding view, which can be called in a URL.

3. The SQL Model and Rails

In order to simplify our project we have combined the two tables (passenger_origin and passenger_destination), into a single table called passengers for these workshops. Now each table row will represent an object instance and each of the twelve (12) columns is an object attribute.

The simplest database operations are often described as CRUD (Create, Read, Update and Destroy). In a single table MVC example there are three main steps with you MySQL tool are:

1. Design the passenger model and attributes;

2. Instantiate the model with a database table and Ruby code

3. Develop a basic controller to do CRUD operations on the Passenger model objects.

If the simplified data model for our project is called Passenger (it is convention to name the model beginning with an upper case letter). The model is then a Ruby class located in app/models/passenger.rb. The SQL table is passengers – the pluralisation of the model.

The controller methods live in app/controllers/passenger_controller.rb

Each controller can access templates to display the input screen and methods for action.

The views are kept is app/views/passenger/*.rhtml, where each *.rhtml maps to a controller method. In Rails, the view is rendered using Ruby-generated RHTML or RXML.

4. More clues on the OTBS database design

OTBS called passenger has a single table called passengers as below:

passengers

name, contact_number, suburb_origin, street, street_number, building, (Unit, house or business) suburb_destination, passenger_number, (1 to 4) taxi_type (sedan, wagon, disabled, maxi), date, time_required

The SQL model is based on the SELECT, PROJECT, JOIN principles of relational databases, with a twist that we now think in terms of a database object via Ruby classes. Let us revise how the four CRUD operations are handled with SQL.

CREATE INSERT INTO passengers
(name, job_id, contact_number, suburb_origin, street, street_number, building, suburb_destination, passenger_number, taxi_type, date, time_required)

VALUES {“Sherlock”, 32832, “0078699”, “Kowloon”, “Baker St”, “42”, “Unit”, “Hawke Bay”, “3”, “wagon”, “2009-01-01”, “0730”}

{“Watson”, 32833, “1234456”, “Pinewood”, “Elm St”, “71”, “Business”, “Hawke Bay”, “1”, “sedan”,”2009-01-01”, “0730”}

READ SELECT * FROM passengers

WHERE (time_required = “0730”

UPDATE UPDATE passengers

SET date = “2009-01-02”

WHERE (name = “Watson”)

DESTROY DELETE FROM passengers WHERE contact-number = “0078699”

Review what was described earlier that the Model is ActiveRecord as Class ActiveRecord::Base to work SQL tables; View is ActionView template files Class ActionView::Base and the Controller is ActionController.

Thus the SQL model becomes a Rails ActiveRecord model and this is a major component of Rails in storing SQL tables and commands which can also be manipulated by collection of Ruby objects. When using SQL JOIN later with other tables, this process is called an object relationship graph abstraction.

5. Scaffolding and the concept of metaprogramming: doing more with less

Scaffolding is a key process during rapid prototyping of your Ruby on Rails project. It uses “metaprogramming” to generate a set of controller methods for the CRUD operations. After defining your model, its attributes and creation of the database table, the basic controller may be called passenger_controller.rb. which can use the scaffold command to release a set of methods to list, show, edit and destroy the database object.

Where do the views come from? Like the old days of “bare bones” programming, scaffolding provides a default set of “undecorated rhtml templates as the views.

There are two ways to scaffold with a simple controller: inline or by passing the model name to a script which can override controller methods and views inside the scripts folder in Rails.

This occurs due to a technique called metaprogramming to create the controller methods which call the method that renders the generic views which can be overridden by later template designs or new SQL schema versions using the Rails migration folder. The scaffold rendering methods in metaprogramming will respect any existing rhtml templates.

In summary try to remember that:

• Rails scaffolding via CoC is a common model of a Web front end to CRUD operations on database objects for a business application;

• Rails uses ActiveRecord database abstraction classes to work with SQL tables, beginng with a class called ActiveRecord::Base

• Metaprogramming creates scaffolding by mapping between instance methods and table columns (attributes)

• Scaffolding gets your application started quickly (rapid prototyping) then you can selectively replace it with later versions;

6. MySQL tools

Many GUI tools exist to support MySQL, such as MySQL Administrator, Migration kit and Query browser (http://www.mysql.com/products/tools/) for Windows, MacOS and Linux. CocoaMySQL is an application used to manage MySQL databases for MacOS users (http://cocoamysql.sourceforge.net/).

At one stage we will have to deal with migration of your prototype to the production site. To get a glimpse of that process in action, see the short screencast at http://www.mysql.com/products/tools/migration-toolkit/tutorials/migrate-sql-server.html


To do:

1. Set up the MySQL tools on your computer as described in section 6 above.

I am using the phpMyAdmin as the MySQL tools on my computer.

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 described in Exercise 5, I am using the XAMPP 1.7.3 for the MySQL, Apache and the phpMyAdmin tools. Moreover, I have download the one-click windows installer "ruby186.27_rc2.exe" from the rubyforge.org which included the Ruby, popular extensions, editor and RubyGems. Afterward, I have setup the Ruby rails by the command "ruby gem install rails --include-dependencies" and morever update the whole system by "ruby gem update --system".

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.

I have created a project call test by "ruby rails test". Then I use the command "ruby rails test -d mysql to change the database.yml file configuration. The content of the database.yml and the localhost:3000 screen are as follow:















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

I had created the passengers table from the otbs databse and insert two passengers according to the data mention in section 4.












Create the model by running the "ruby script/generate model Passenger" and the controller by "ruby Script/generate controller Passenger". A passenger.rb file is created under the "app/models" directory and a passenger_controller file is created under the "app/controllers" directory accordingly.



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/

Done.

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

Done.

Workshop 2

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.

Skipped at this moment, will start on next week.

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

Convention Over Configuration (CoC) is that the framework enforces standard naming conventions for mapping classes to resources. In a general purpose framework, one or more configuration files are required in order to set up the framework. When the complexity and size of applications grow, it is very difficult to maintain the configuration files. Most mapping information can be reflected by the database table structure without the need of any configuration. Therefore, changing the name of the class or method in the source code  will not induced any modification of the configuration file because it is automatically propagated through the application.  (Chen, 2006)

3. Further work on understanding MVC:

a. See the wiki at http://wiki.rubyonrails.org/rails/pages/UnderstandingMVC

The topic doesn't exist.

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

Done.
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

Not have enough time this week, will do it on next week.

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

Done.

Recommended time: 1-4 hours.

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.


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

From the hint, I will using a Passenger table inside the SQL database  as the "Model", then I will create a set of methods (codes) to read, write, modify and delete the data inside the database which is the "Controller" and moreover a "View" which provide a UI for the users which maps with the controller's method.

Sunday, April 18, 2010

Workshop 1

Workshop 1 - Setting up the model railway

Topic objectives

• Install Ruby on Rails on your computer (InstantRails or Locomotive);
• Learn about the Model View Controller (MVC) approach to Web application design;
• Revise database techniques with MySQL
• Learn how to use 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


Topic Resources

Many resources exist online to help to learn about Ruby on Rails, so this list of resources can be our point of departure. The workshop reading is RailsSpace: Building a Social Networking Website with Ruby on Rails and is a Safari online book and is accessed through the CSU Library and is explained below. Another list of books exist at http://www.buildingwebapps.com/books/list?category=5

The Learning Rails Podcast series at http://www.buildingwebapps.com/podcasts
may suit you and the Javascript Videos 1-4 at http://video.yahoo.com/watch/111593/1710507
by Douglas Crockford on The JavaScript Programming Language is useful if looking at the use of AJAX with Rails.

Topic reading from Safari Books Online

Hartl, M & Prochazka, A, (2008). RailsSpace: Building a Social Networking Website with Ruby on Rails, Pearson Education

The workshop reading is a Safari online book and is accessed through the CSU Library.

Use the keyword ‘railsspace” to search for access to this eBook via your CSU Library access.‘RailsSpace’ shows how to build large-scale projects with Rails by developing a social networking website like MySpace or Facebook.

This raises issues around scalability, flexibility, capacity planning and performance testing. The companion website at http://railsspace.com/book
has many resources for each chapter, sample code and the final application as a zip file. The same development approach in ‘RailsSpace’ can also be applied to the Online Taxi Booking Service where regular customers can be included as members of an online community business model or an extended customer relationship management model.

Discussion

One way to learn a Web application framework is by building a project. It’s like driving a train – you can’t learn to do it by reading a book. In this workshop series we shall use the Online Taxi Booking System as the “train”, you the developers are the passengers, and the train rides the Rails under commands from Ruby.





The Project

The sample Ruby on Rails Project is the Online Taxi Booking System as briefly described in the subject outline with more details added later during session via the forum or CSU Interact. Use database design techniques and the model view controller design (MVC) approach. The database-driven website is developed and tested on your local PC using Ruby on rails and Web browser, before being migrated to a production site on the CSU network.

The database called taxi has TWO tables called passenger_origin and passenger_destination:

Passenger_origin:

Name, Contact No., Suburb, Street, Street No., Building (Unit, house or business);

Passenger_destination:

Suburb, No. of passengers (1 to 4), taxi type, time required;


To do:

1. Download iTunes from http://www.apple.com/itunes/download/ and subscribe to the “Leraning Rails” Podcasts from http://www.buildingwebapps.com/podcasts

Done

2. Install Ruby on Rails on your computer by using the material and downloads from http://www.rubyonrails.org/

Done
3. Rather than get Ruby on Rails running manually, you use the pre-packaged solutions. These include everything in one bundle: Web server, database, Ruby, Rails, the works.

a. For OS X, there's Locomotive.

b. For Windows, there's Instant Rails. 

Windows platform selected. Done.


Recommended time: 1-4 hours.


Challenge Problems:

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 before we begin.

As I stated in my introduction, I have no experience on any Web development tools in my prior experience. I have been learnt a lot of programming languages during my college in 1989-1992. They are Pascal, C, C++, Prolog, Lisp, Ada, Assembly language for 68000.

From my understanding, a Web application frameworks is a package of tools (program language, library, interface design, etc.) which can help to develop the Web application in an efficient way. Unlike the old style programming language in the past, programmer needs not to take care a lot of ground work like HW configuration, GUI coding, connectivity issues.

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 is created by Yukihiro "matz" Mastsumoto and publice release in 1995. Matz (2001) metions that he wanted a scripting language that was powerful than Perl and more object-oriented than Python.

It is based on Matz's favorite languages (Perl, Smalltalk, Eiffel, Ada adn Lisp) and is a balanced functional programming with imperative programming. It can be use, copy, modify and distribute freely.
 
Everything in Ruby is an object and any information and code can has its own properties and actions (even numbers and other primitive types). Ruby has a high flexibility, it allows users to alter its parts. Essentail parts can be removed or redefined, existing parts can be added. On purpose, Ruby features single inheritanc only and it is a much clearer way than multiple inheritance (complex and restrictive).

Besides that, Ruby has a lot of other features, such as exception handling, a true mark-and-sweep garbage collector for objects, a SWIG interface, load extension libraries dynamically, OS independent threading and highly portable. (ruby-lang.org, 2010)

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

Rails is a Web development framework written in Ruby language which can make programming  web applications easier by writing less code and accomplishing more than other languages and frameworks. It is an opinionated software (add-on) for Ruby. The main philosophy for Rails are "Don't Repoeat Yourself"(DRY) in writing the same code, Converntion Over Configuration (COC) - assume what you do and how you do, and Web application in RESTful practice (Rubyonrails.org, 2010).

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

COC means Rails assumes what the users want to do and how they are going to do it. It will save a lot of time for the user to tweak every little things by go through different configuration files (Rubyonrails.org, 2010).

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

Model-View-Controller (MVC) was begun in 1979 by Trygve Reenskagu and working on Smalltalk at Xerox PARC (wikipedia, 2010).

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

MVC design approach specifies that an application consists of a data mode (Model), presentation information (View) and control information (Controller). For example in a Java web application design, the Model is a collection of Java classes that perform  the actual work of the application  (business logic), the View is a collection of JSP that produces the actuall web pages for the users to see and the Controller is one or more servlets that handle the browser requests by telling the Model what to do and then transfer it over to the View to respond.

Wednesday, April 14, 2010

Exercise 7

1. Why is the perception getting stronger that integration will become a critical factor in coming days?


Nowadays, e-commerce will involve a lot of Business-to-Business (B2B) communications. Information (data) needs to transfer from one platform into another platform within trading partners. Those trading partners will have its own islands to handle their own e-commerce data, thus successful e-commerce model will involves how they can efficiently handling data exchange. Integration is the main direction in order to achieve a best e-commerce model. In an integrated environment, due to well-designed communication method (data format and protocol), the communication is more streamlined and therefore B2B visibility will be enhanced. Business decision will be made much faster to respond for the market need and it is a critical factor for a business to success in the coming days.


2. What is the relationship of AJAX to JQuery (jquery.com) and the lightweight Web 2.0 JavaScript framework called MooTools (mootools.net) within the enterprise software architecture?

In JQuery site (2010) states that "jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript."

In mootools.net (2010) states that "MooTools is a compact, modular, Object-Oriented JavaScript framework designed for the intermediate to advanced JavaScript developer."

It is very clear that they are both open-sourced JavaScript libraries which can improve the efficiency for developing the enterprise software (rapid development). They helped the WEB developer to implement flexible, powerful and multiple browser coding on the fly.

3. What are the similarities between the object-oriented development using model-view-controller (MVC) in Ruby on Rails 2.0 and Action Script 2.0 (Flash animations)?

Ruby on Rails 2.0 (RoR) and Action Script 2.0 (AS) both are object-oriented development tools using MVC model to achieve rapid WEB development. They are both class-based cross-platform (OS) tools to develop internet applications and websites relied on WEB servers. They are both language dependent tools which RoR is based on ruby and AS is mainly based on ECMAScript - similar to JavaScript.

4. What does it mean to develop RESTful practices into our web applications?

A Representational State Transfer (REST)ful practices means to make our web service (Client-Server) application communication with standardization. REST is related to the Service Oriented Architecture base on resources by putting some constraints into application architecture and has the following properties: scalability, performance, security, reliability, and extensibility. (Hao, 2004)

Exercise 8

Create an XML document for an online catalogue of cars where each car has the child elements of make, model, year, colour, engine, number_of_doors, transmission_type and accessories. The engine has child elements called number_of_cylinders and fuel_system.


I have download a very handy tools XML notepad 2007 from microsoft to create the required XML document. It is a very user friendly tools and I have insert the catalogue as follow:
















The final XML file is as below:

















Saturday, April 10, 2010

Exercise 6

1. Design the form
    'Retrofit' the form data string below:
name=Evan+Burke&card=Visa&number=8443261344895544&order=French+perfume
    for buying some French perfume into the HTML form fields and submit button on te Web page form.

I am using the HTML coding below to create the form. I am use the GET rather than the POST function as I can see the submit data is correct.












The created form showed in the Internet Explorer is like this:


















By hitting the Submit button, the entered data is submit into the server. The form's fields will clear up and the transfered data will show on the address bar.












2. Write the script
Script archives exist for PERL, Python and JavaScript. Search the Web for a script that processes the HTML forms data. Read the code and list the steps involved in processing the form.

After searching the Web, I found a JavaScript archive in the Javaworld.com which can processes the HTML forms data. This Java Script is very simply, it reads the data from "myform" and then display the result on the browser screen. The JavaScript coding and the execution process and result are show as follow:














Execution process



















Result


















3. Can you modify the script to process the form?

Yes, of course. First of all, I need to update the JavaScript form structure in order to fit the data string. Afterward, I will add more lines  in the JavaScript in order to display the submit data on the browser by the user.

The modified coding is as below:
















The execution process is:





















The final result is:




4. Improve the user experience by add a Javascript feature.

In order to imporve the user experience, I have add a Javascript feature which prodvide a drop down selection list for the Card option and moreover a pop up window to show the card selection from the drop down menu.

The modified coding is as below:





















The pop up window will show the user has selected the Master card.


















After press the Submit button, the browser will show all the inputed details.





















Friday, April 9, 2010

Exercise 5

Database case study

Do EITHER Case A or Case B as your database case study for this exercise.
On your own machine, setup and testeither database system and report your findings.

I will use Case B as my database case study for this exercise.


Case B: PHP and MySQL

Some server practice with PHP

Instead of using individual versions of PHP, MySQL, phpMyAdmin and Apache, I'm using the XAMPP 1.7.3 for window which is a setup packing for PHP 5.3.1, MySQL 5.1.41, Apache 2.2.14 and phpMyAdmin 3.2.4. The installation process is very simply and it only takes about 5 minutes to finish. This XAMPP is a lite and green version which it will not install any services in the windows environment.

After installation, the Apache is not working due to the Skype install in my computer is using the port 443. I need to close the Skype application in order to turn on the Apache service.

1. Examine the environment variables on the server, the coding is as below
















The result is as follow















2. Create a web application , hello_world.php










The result is as follow
















3. Create an HTML page with teh form:













4. Then, Create a PHP file named submit.php with the following code:













The coding has been modified from $myname into $_GET[myname] in order to work.

The result for 3 and 4 is as follow:















After press RETURN, the result is as follow:















5.

a. Create a web page, the corresponding code is as follow:













The result is as follow:
















Because the mydatabase is empty, I need to use the phpMyAdmin tool to input the employee data into the employees table in order to give the output.


b. Create the add_record.html














c. Create the corresponding add_record.php with the POST method:

The original code provided by the study guide is not written for the windows environment. I need to change the $first,$last,$address,$position into $_POST[first], $_POST[last], $_POST[address],$_POST[position],
in order to make the program to run. Moreover, there is also a typo mistake in the original coding, the INERT needs to correct into INSERT.












The execution result is as follow:
















After putting in the required data and press the Enter, the result is as follow:













d. Get multiple records from the database

The correct coding is as below:













The original coding in the study guide is not grabbing the correct data from the employees database. The first, last, address and position is count from 0 to 3 rather than 1-4. Therefore the $myrow[2] and $myrow[1] needs to change to $myrow[1] and $myrow[0] correspondingly.

The result is as follow:

















Task completed.

Conclusion

This is a very good exercise to understand the PHP and database relationship. But it is very time consuming for setup and moreover a lot of steps is not cover in the study guide. I had used almost 10 hours to finish this exercise. Fortunately, by follow the blog from Leo Lee  and read some hints from the internet (w3schools,2010), I can finally finish the task.

Thursday, April 8, 2010

Exercise 4

1. Describe the important and distinguishing properties of Peer to Peer computing with the client/server architecture?

Peer to Peer (P2P) computing refers to network connections bypass the server and the two hosts (peers) are communicate with each other. In enterprise level network, most of the data exchange is going through the client/server architecture and is handled by the centralized server. The centralized server take care all the security and data exchange roles. The important of P2P computing is that it can reduce the traffic load on the centralize server as all the communications and resources are handle by both peers. The hosts in P2P computing will share their local information, such as files, music, movies, etc. from each other and it is widely distributed among the network unlike the client/server architecture which all information is stored inside the server.


2. Frameworks for development. Compare and contrast any TWO of:

a. Java b. .Net c. Ruby on Rails d. Turbo Gears e. Google Gears f. AJAX frameworks

I will compare and contrast on Java and .Net.

1. Java and .Net are based on virtual machine model which the program will not need to take care about the hardware configuration.

2. The program language for C# and VB used in .Net has a lot of similarities with the JVM and Java

3. Both .Net and Java are supporting multiple programming languages.

4. .Net can only be installed in Microsoft windows environment, but Java can be installed on a variety of operating systems (windows, Linux, Mac)

5. Java is an open source but .Net is a commercial product which the .Net framework base class library will only for reference purpose.
(Wikipedia, 2010)

Exercise 3

1. Explain DNS and DHCP.

Domain Name System (DNS) is the hierarchical naming system for the computers connected to the internet or a particular private network. It is always running in a server which stores all the computer's naming conversions within the domain. The main function of a DNS is to convert the human understand computer hostnames or internet domain names into Internet Protocol (IP) address. For a universal internet DNS server, it always stores all the registered domain names around the world. Of course, there are different levels of DNS servers act as authoritative name server which will handle sub-level naming conversion request. It will make the DNS system becomes distributed, fault-tolerant and avoid a single point of failure.

Dynamic Host Configuration Protocol (DHCP) is a networking protocol used by the network clients (equipment which require IP address) to obtain IP address and other necessary network parameters (DNS server). It is a client-server based design which the DHCP client will broadcast the network information request to the network, the DHCP server will respond and send back the IP address and network parameters. All those dynamic data will have expiration, therefore depending on the client OS design, they need to request the DHCP data refreshment from time to time. Without the DHCP service, all the clients need manually configure for the IP address and network parameters.

How does DNS differ from DHCP configuration?
As describe above, DNS only store the naming conversion within the domain and DHCP is responsible for the network information assignment. They are totally differing from each other, but in the real world, they are always working together. DHCP helps to distribute the DNS server IP address to all the clients and all the clients can use the DNS server content to go out to the Internet.

2. Why is it important for your online business application to use a static IP address rather than have it dynamically assigned?

Static IP address is almost a must because an online business customer will use internet browser to access the online application by typing in the site name (www.onlinebusiness.com). Such internet naming conversion is handling by the DNS server pointing by the customer's computer. We need to understand that the DNS servers around the world are not using real time synchronization and it takes a huge time for doing so. If the online business application is not using static IP address, the customer's DNS server may not have the correct IP address pointing to the online business server. Therefore, the customer cannot reach the online application and there is no business happens. Customer will not wait and re-visit the online business site again afterward. E-commerce is a 24 X 7 business.

3. What role can the following play in business-to-business e-commerce?

a.Virtual Private Network (VPN)

VPN is important for business-to-business e-commerce as it provides a secure tunnel for data exchange underlying the network traffic (internet). Without VPN, business-to-business e-commerce will need to go through a dedicated lease line which is too expensive and not flexible.

b. Next generation of wireless mesh networks

The wireless mesh networks will enlarge the coverage of the internet in the rural area and moreover it can provide a more stable and expandable networking environment than the wired ad hoc network. For e-commerce this is very important as high good quality coverage implies more business opportunities.

c. Social Cloud applications

Social Cloud applications will help the e-commerce business to cut down the application developing cost and time. Moreover, in business-to-business environment, using social cloud application means both sides are starting from the same ground. Therefore, the integration and communication between e-commerce will become seamless.


4. If clouding computing is the 'balck box', then grid computing is a component as the 'white box'.

Explain what you interpret about that statement.

Grid computing is a cluster of computers using a parallel processing architecture where the CPU resources are shared across the network acting as one large computer. Cloud computing is a set of dynamically scalable, virtual services over the Internet. (Eustace, 2010)


From my point of view, such statement is true if we are looking from a computer hardware standpoint. For grid computing, we can absolutely understand the infrastructure of the system, the amount of resources that can be allocated and more likely the system performance. For clouding computing environment, everything is unknown. We don't where the data is located, the system performance and reliability.

Exercise 2



Describe the steps involved with the Rapid Evolutionary Prototyping Approach as it applies to developing a Web application.

There are four main steps involved with the prototyping process

1. Identify the basic user’s requirements including inputs from the users and outputs from the applications.
2. Develop the initial prototype which only include the user interfaces
3. Review and examine the prototype by stakeholders (customers, end-users), then collect feedback on additional requirements or changes.
4. Enhance (features) and revised the prototype (plan) according to the feedback and changes.

Step 3 and 4 will iterate until the final prototype meets the contract requirements.

For Rapid Evolutionary Prototyping Approach (REPA) in developing a Web application, it will mainly follow the 4 steps above but with some enhancements. This approach depends on reuse of software components, use of software templates and on an architectural template. Moreover, the development process focus on multiple small teams working engineering discipline (parallel) and frequently customer interaction in a timebox manner according to a particular function of a software project(Wikipedia,2010).


How is it related to agile development?

Agile development is a term for iterative and incremental software development methodology. (Versionone, 2010). REPA is exactly using the iterative and incremental method to speed up the developing process of the application. This approach involves continuous planning, testing, integration and other forms of evolution of the project and the software. In addition, the REPA is lightweight and focus on force stakeholders to collaborate and have decisions quickly and effectively.

Reference

Exercise 2

Versinone 2010, Agile Development, viewed 7 April 2010.
http://www.versionone.com/Agile101/Agile_Development.asp

Wikipedia 2010, Software Prototyping, viewed 7 April 2010.
http://en.wikipedia.org/wiki/Software_prototyping#Evolutionary_prototyping


Exercise 3

Eustace, K 2010, Cloud and grid architecture, E-Systems Infrastructure Development Study Guide, p. 10.

Exercise 4

Wikipedia 2010, .Net Framework, viewed 8 April 2010.
http://en.wikipedia.org/wiki/.NET_Framework#.NET_vs._Java_and_Java_EE

Exercise 5

W3schools 2010, PHP MySQL Insert Into, viewed 8 April 2010.
http://www.w3schools.com/PHP/php_mysql_insert.asp

Exercise 6

Javaworld 2010, Using JavaScript and forms, viewed 9 April 2010.
http://www.javaworld.com/jw-06-1996/jw-06-javascript.html

Exercies 7

jQuery 2010, jQuery is a new kind of Javascript library, viewed 15 April 2010.
http://jquery.com/

Hao, H 2004, Implementing REST Web Services: Best Practices and Guidelines, viewed 15 April 2010.
http://www.xml.com/pub/a/2004/08/11/rest.html?page=1

Exercise 9

Chen 2010, SSL v.s. SET, viewed 14 May 2010.
http://itchen.class.kmu.edu.tw/crypto/slides/SSL&SET.ppt


Dictionary.com 2010, phishing, viewed 14 May 2010.
http://dicitionary.reference.com/browse/phishing

Ecommerce-guide 2010, Secure Electronic Transaction, viewed 14 May 2010.
http://e-comm.webopedia.com/term/s/secure_electronic_transaction.html

Eustace, K 2010, Internet Security, E-Systems Infrastructure Development Study Guide, p. 46-49.

Internet Security Systems 1998, Network-vs. Host-based Intrusion Detection, viewed 14 May 2010.
http://documents.iss.net/whitepapers/mvh_ids.pdf

Wikipedia 2010, HTTP cookie, viewed 14 May 2010.
http://en.wikipedia.org/wiki/HTTP_cookie#Drawbacks_of_cookies

Wikipedia 2010, RSA, viewed 14 May 2010.
http://en.wikipedia.org/wiki/RSA


Exercise 10

Lundh, F 2007, Thread Synchronization Mechanisms in Python, viewed 14 May 2010.
http://effbot.org/zone/thread-synchronization.htm#synchronization-between-threads

Microsoft.com 2010, Waitable Timer Objects, viewed 14 May 2010.
http://msdn.microsoft.com/en-us/library/ms687012(VS.85).aspx

Webopedia.com, Deadlock, viewed 14 May 2010.
http://webopedia.com/TERM/d/deadlock.html

Webopedia.com, Event, viewed 14 May 2010.
http://webopedia.com/TERM/e/event.html

Webopedia.com, Mutex, viewed 14 May 2010.
http://webopedia.com/TERM/m/mutex.html


Exercise 11

Pcmag.com 2010, TP monitor, viewed 14 May 2010.
http://www.pcmag.com/encyclopedia_term/0,2542,t=TP+monitor&i=53022,00.asp

Wikipedia 2010, ACID, viewed 14 May 2010.
http://en.wikipedia.org/wiki/ACID

Exercise 14

Jones, T. 2006, Build a Web spider on Linux, viewed 23 May 2010.
http://www.ibm.com/developerworks/linux/library/l-spider/

Wikipedia 2010, Software agent, viewed 23 May 2010.
http://en.wikipedia.org/wiki/Software_agent

Exercise 15

Nielsen, E. 2006, Mobile and Dynamic Web Services, viewed 23 May 2010.
http://ftp.informatik.rwth-aachen.de/Publications/CEUR-WS/Vol-234/paper8.pdf

Wikipedia 2010, Location-based service, viewed 23 May 2010.
http://en.wikipedia.org/wiki/Location-based_service

Wikipedia 2010, Open Mobile Alliance, viewed 23 May 2010.
http://en.wikipedia.org/wiki/Open_Mobile_Alliance

Exercise 16

Savvion 2009, Business Process Analysis, viewed 23 May 2010.
http://www.savvion.com/business_process_analysis


Workshop 1

Rubyonrails.org 2010, What is Rails, Getting Started with Rails, viewed 15 April 2010.
http://guides.rubyonrails.org/getting_started.html#what-is-rails

Ruby-lang.org 2010, About Ruby, viewed 16 April 2010.
http://www.ruby-lang.org/en/about/

Wikipedia 2010, , Model-view-controller, viewed on 15 April 2010.
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller#History


Workshop 2
Chen, N 2006, Convention over Configuration, viewed on 18 April 2010.
http://softwareengineering.vazexqi.com/files/pattern.html


Workshop 4

Dan 2007, 3 things that Javascript and Ruby have in common, viewed on 20 April 2010.
http://www.javascriptkata.com/2007/04/05/3-things-that-javascript-and-ruby-have-in-common/



Workshop 5

Rubyonrail.org 2010, Module ActionController::RequestForgeryProtection::ClassMethods, viewed on 22 May 2010.
http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html

Ryan 2007, What's New in Edge Rails, viewed on 22 May 2010.
http://ryandaigle.com/articles/2007/9/24/what-s-new-in-edge-rails-better-cross-site-request-forging-prevention


Workshop 7


Begin, C. & Tate, B. & Zygmuntowicz, E. 2008. Deploying Rails Applications, viewed 25 May 2010.
http://media.pragprog.com/titles/fr_deploy/chap6.pdf

Modrails.com 2010, Phusion Passenger User Guide, viewed 25 May 2010.
http://www.modrails.com/documentation/Users%20guide%20Apache.html

Railshostinginfo.com 2010, Setting up a webserver for Rails, viewed 25 May 2010.
http://www.railshostinginfo.com/static/setting_up_a_webserver_for_rails

Rubyonrails.org 2010, Deploying Ruby on Rails is easy, viewed 25 May 2010.
http://rubyonrails.org/deploy

Wikipedia.org 2010, Apache Subversion, viewed 25 May 2010.
http://en.wikipedia.org/wiki/Apache_Subversion