Friday, 8 May 2009

WK1: What is "Ruby on Rails"?

First of all, we need to have an overview on "Ruby on Rails".




  • Ruby is a cross-platform interpreted language which has many features in common with other ‘scripting’ languages such as Perl and Python. However, its version of object orientation is more thorough than those languages and, in many respects, it has more in common with the great-granddaddy of ‘pure’ OOP languages, Smalltalk. The Ruby language was created by Yukihiro Matsumoto (commonly known as ‘Matz’) and it was first released in 1995.




  • Rails (often called simply “Rails”) is a framework for building web applications with Ruby.




    • Honestly, it was not easy to get it to work properly. Basically, it is just a development tool and therefore, I need another two components for the MVC project which are the web server and the database. I chose Apache and MySQL as the other two components. I have some exprience with the MVC development approach. The tools I am familiar with are SQL Server, IIS, ASP, VB script and Javascript. I have ever used these tools for the MVC project.

      I have taken hours to install Ruby and MySQL on my Vista machine. I just think my Vista machine is not very stable and also, I am not sure whether I have installed the right version of Ruby and MySQL on it. With such uncertinty in mind, I decided to take a step back and download the comparatively mature version of Apache, MySQL, PHP and Ruby and installed on my another machine on which Windows XP are running. Finally I take a short cut by installing Instant Rails. However, I can't believe I have been struggling for a couple days with the setup of "Ruby on Rails".

      In the first place, I really wanted to take a shortcut by installing "Instant Rails" on XP machine. However, I couldn't get it tp work very well. The problem is I have actually installed MySQL 5, Apache 2 and PHP 5 on my machince and then, I still put on "Instant Rails". Basically, two different versions of the mentioned software are running on my machines. I have been working very hard to resolve the conflicts among them. Then, I switch to my Vista machine and try to install "Instant Rails" again. Before I do this, I need to uninstall MySQL & Ruby from this machine first. I couldn't believe I could still get a strange error. This time the PHP library couldn't be loaded. Eventually, I could manage it to function as expected after a few tries. The following Youtube video clip is an excellent demonstration on installing "Instant Rails" on Vista. Great ! I can move on.

      http://www.youtube.com/watch?v=xbKV1sndLGo&eurl=http%3A%2F%2Fbroadcast%2Eoreilly%2Ecom%2F2008%2F12%2Finstalling%2Dinstant%2Drails%2Don%2Dwi%2Ehtml&feature=player_embedded

      I summerise the steps as follows:

      1.Unzip InstantRails-2.0-win.zip
      2.Click OK to locate config files
      3.Manage Rails Applications
      4.Creata New Rails App...
      5.Create a New Rails Application by typing "rails hello" at command line
      6.Start with Mongrel
      7.Test the host with IE by typing "http://127.0.0.1:3000/"
      8.Diplay "Welcome aboard" web page



      9.Open Ruby Console Window to generate code
      10.Go to application directory (e.g...rails_apps\hello>ruby script/generate controller hello index)
      11.Open Windows EXplorer to view the files of hello
      12.test "hello" with IE by typing "http://127.0.0.1:3000/hello"

      Great! This is the first web application I created by Ruby on Rails

      References

      Collingbourne, H. 2008, The Little Book Of Ruby, 2nd edn, Sapphiresteel Software, Dark Neon Ltd., also available as pdf file, viewed 9 MArch 2009,

      Saturday, 2 May 2009

      XML Introduction

      It is relatively simple to verify that a document is well-formed or validated XML, because the rules of well-formedness and validation of XML are designed for portability of tools. The idea is that any tool designed to work with XML files will be able to work with XML files written in any XML language (or XML application). You can use Firefox or Internet Explorer (which is embedded with XML parser) to load XML documents. Besides you can parse the XML documents in Ruby (Wikipedia 2009).
      If the XML schema for business sector can be standardised, it will greatly improve the data exchange in e-commerce transactions. As I mentioned earlier, HKIPD provides the efiling services to filers so they can choose to file their Trademark/Patent/Design applications via the internet. Basically, the filers need to convert all the supporting documents to the XML format according to the schema issued by HKIPD and submit them together with the application to the designated website. For patent applications, sometimes the supporting documents are over hundred or even thousand pages and can be found from other overseas IP offices. If the XML schema is standardised in the Intellectual Property context, this will enhance the data exchange among within the industry.
      W3C defines "SMIL" as follows:
      The Synchronized Multimedia Integration Language (SMIL, pronounced "smile") enables simple authoring of interactive audiovisual presentations. SMIL is typically used for "rich media"/multimedia presentations which integrate streaming audio and video with images, text or any other media type. SMIL is an easy-to-learn HTML-like language, and many SMIL presentations are written using a simple text-editor.
      With using it, the multimedia presentations on the Internet will be handled by the same standard. This will greatly ease the multimedia development over the Internet.

      References

      W3C 2003, Synchronized Multimedia, W3C Interaction Domain, viewed on 28 April 2009, <
      http://www.w3.org/AudioVideo/>.

      Wikipedia 2009, XML, Wikipedia, The free encyclopedia, last modified 27 April 2009, Wikimedia Foundation, Inc., US, viewed 30 April 2009, <http://en.wikipedia.org/wiki/XML>.

      Friday, 1 May 2009

      Application Server Platforms in e-commerce

      The top Database Systems suppliers have issued their e-commerce products/solutions. Refer to the following table, you would see MySQL and its partners have issued the most e-commerce applications. All the while, MySQL is an open source database system as being claimed "The world's most popular open source database" in its official website.




      What is AJAX?

      I summarise the information about AJAX from (W3Schools n.d.). AJAX stands for Asynchronous JavaScript and XML, which is not a new programming language, but a technique for creating better, faster, and more interactive web applications. With AJAX, your JavaScript can communicate directly with the server, using the JavaScript XMLHttpRequest object. With this object, your JavaScript can trade data with a web server, without reloading the page. AJAX uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages.The AJAX technique makes Internet applications smaller, faster and more user-friendly.

      The web standards used in AJAX are well defined, and supported by all major browsers. AJAX applications are browser and platform independent. In other words, the web pages that developed by AJAX can be run across different platforms (e.g. .NET or Java). Now "Web 2.0" gives us a direction of future development of the Internet. I quote the following statement from (Wikipedia 2009).

      Web 2.0 is the business revolution in the computer industry caused by the move to the Internet as a platform, and an attempt to understand the rules for success on that new platform.

      Banerjee (2001) believed that Java and .Net will converge one day as a single platform before the concept of "Web 2.0" was introduced in 2004. The Internet is becoming a develpment platform. It is moving a step forward by using AJAX to develop the internet applications. AJAX can enrich the web interfaces so that the interactivities of web applications are highly improved. For example, Flickr adopted the Web 2.0 cencept. Nowadays enterprises are adopting the approach of social network. Instant Message is widely used in some commerical organisation. It also means AJAX will be taking an important role in the enterprise software architecture. The corporate interanet or extranet will be moving to this direction.

      The mode-view-controller (MVC) is the paradigm of distributed system. In MVC, the model represents the information (the data access) 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 logics used to manipulate the data to and from the model (Wikipedia 2009).

      Actionscript and Ruby on Rail both object oriented pragramming language and use MVC paradigm to develop web based applications.

      References

      Banerjee A 2001, .NET framework comparison with Java Architecture, Mindcracker Network, viewed on 26 April 2009, <http://www.c-sharpcorner.com/UploadFile/abanerjee/DotNetforJava11292005023419AM/DotNetforJava.aspx>.

      W3Schools n.d., AJAX Introduction, viewed on 24 April 2009, <http://www.w3schools.com/Ajax/ajax_intro.asp>.

      Wikipedia 2009, Web 2.0, Wikipedia, The free encyclopedia, last modified 1 May 2009, Wikimedia Foundation, Inc., US, viewed 29 April 2009, <http://en.wikipedia.org/wiki/Web_2.0>.

      Wikipedia 2009, Model–view–controller, Wikipedia, The free encyclopedia, last modified 1 May 2009, Wikimedia Foundation, Inc., US, viewed 29 April 2009, <http://en.wikipedia.org/wiki/Model-view-controller>.

      Wednesday, 29 April 2009

      PHP and MySQL database access

      I created a database named "mydatabase" and a table named "employees" in MySQL.

      I inserted one record into the Employees table and try to execute the PHP script to show the record.

      I always get the error message "HTTP 500 - Internal server error..." and then I check the Apache errorlog and find out the real cause is "PHP Fatal error: Call to undefined function mysql_connect()". Finally, after I have read through the following url, I know how to fix the problems now.


      http://docs.phplivesupport.com/viewarticle.php?uid=1&aid=73&pid=3

      I really don't know why I always engage with the setup problems but really thank God I can resolve them eventually. This is a good exprience.




      I insert a new record through "add_record.html".



      The new record is uploaded to the table correctly by "add_record.php".

      I execute the script show_records.php to display multiple records.

      Tuesday, 28 April 2009

      Perfume Order Form

      I modified a pizza order form sourced from (Pickering, Powers & Johnson 1996) and which becomes the following Perfume Order form.

      ***************************************************
      French Perfume

      Pricing:

      high
      medium
      low

      Quantity



      Brand Name



      Fragrance Accessories:

      Body Spray
      Body Lotion
      Shower Gel
      Body Mist
      Aftershave
      Deodorant
      Body Roll On

      Name

      Address












      ***************************************************

      Not long ago I wrote a web form illustrated below which is being used in my form for handling IT equipment loan requests. The web form is an ASP web page written by both Visual Basic script and Java script, which is running on Microsoft Internet Information Server (IIS) platform. Behind the scene, the program is very complex as it incorporates a lot of business logics. In brief, it serves the following purposes:

      1. Check the access right of users as a measure of security
      2. Capture the data from users
      3. Validate the data through the field controls, the client side programming
      4. Pass the data to the middle tier programmig for examination (the business logics incorporated in the store procedures, the middle tier programming)
      5. Click "Submit" to post the data to the database, the backend server (if no error is found)
      6. Repeat step 2 to 4 until the data is posted successfully (if error(s) is/are found)

      Can you modify the script to process the form?

      The answer can be Yes or No. It really depends on how large degree you have modified the scripts of the form. Normally the web form will not be workable in other system ( I do not mean the platform e.g. IIS or Apache) even though you have modified the source codes/scripts. Because the web form is just the user interface of the web application and the business logics would be embedded in the client side programming for "thick client" and in the middleware or backend server for "thin client". For the web application with think client approach, you can modify the scripts of the web form according to the business logics of your application and process it on your system. However, this is not an easy task, you nearly reprogram the application in order to make it to work on your system. For thin client application, this is much more possible, you only need to change the field controls of the form to meet the requirements of the business logics.

      Reference

      Pickering G, Powers S & Johnson R 1996, Javascript How-To: The Definitive Javascript Problem-Solver, CH08, HT0801.HTM, CD-ROM, Waite Group Press.

      User Input for database access with PHP


      I don't know why the parameter doesn't show on the php page but definitely, it has been successfully passed to it. Any idea? Finally, I can work out why the parameter was shown on the php web page. This is due to the syntax issue of different version of php. I replaced the varaible $myname with $_GET["myname"]. It works.





      Some server practice with PHP


      I don't know why I can't get the values of the variable including ($REMOTE_ADDR $SERVER_NAME and $PHP_SELF) when running the EX61.php. But it works well with "hello_world.php" as well as "php_info.php".


      After I have checked the ITC 594 Forum, I resolve the problem now.

      Thanks a lot!