Thursday, March 25, 2010

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.

I have set up a study group called Team 007 in Wiki took, at CSU’s Interact Intracnet.


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

From the Wiki definition, Convention over Configuration (CoC) is a ‘software design paradigm which seeks to decrease the number of decisions that developers need to make, gaining simplicity, but not necessarily losing flexibility.’

CoC reduce coding by relating the database to the class by default, e.g. the corresponding table in a table with the class ‘Sale’ will be automatically named as ‘Sale’. Unless there is exception, then needs to be specified.


3. Further work on understanding MVC:

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

Error message ‘This topic does not exist’

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

The tutorial described the origin of MVC.

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

How can this guy keep speaking that fast?

References

Wikipedia. (2009). Convention over Configuration. Retrieved on 26 March 2010, from http://en.wikipedia.org/wiki/Convention_over_configuration



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.


From the Wiki, Rails use the Model-View-Controller (MVC) architecture as a design framework. (Wiki, 2010) When an application is created, the data of a specific application (like the Taxi) is stored in a directory structure with folder 'app/controllers', 'app/views' and 'app/models'

More about the directory structure is set up. Below is the example extracted from a RoR tutorial. (Ruby on Rails 2.1.x - Directory Structure, n.d.)

The application is called demo, steps below.

C:\ruby\> rails -d mysql demo

Now go into demo application root directory as follows:
C:\ruby\> cd demo
C:\ruby\demo> dir

You will find a directory structure as follows:
demo/
..../app
......../controller
......../helpers
......../models
......../views
............../layouts
..../config
..../db
..../doc
..../lib
..../log
..../public
..../script
..../test
..../tmp
..../vendor
README
Rakefile

References
Tutorial Points. (n.d.).Ruby on Rails 2.1.x - Directory Structure. Retrieved on 26 March 2010 from http://www.tutorialspoint.com/ruby-on-rails-2.1/rails-directory-structure.htm

Tuesday, March 23, 2010

Exercise 5 (Q5)

5. Use the PHP to work with MySQL database

Before go into part a to d. First to create the database “mydatabase” with the phpMyAdmin.

Step 1: Create the Database ‘mydatabase’ (5_5_1)


Step 2: Create Table ‘Employees’ (5_5_2)


Step 3: Create the Fields (5_5_3)


Step 4:Table Created (5_5_4)


Step 5: Input record (5_5_5)


Step 6: Record inserted (5_5_6)


Step 7: Display record (5_5_7)


a. Create a web page with the following PHP: (5_5_a)


Running result (5_5_a2)


b. Create “add_record.html” (5_5_b)


Running result (5_5_b2)


c. Create “add_record.php” (5_5_c)


Running result (5_5_c2)


d. codes to get multiple records (5_5_d)


Running result (5_5_d2)

Sunday, March 21, 2010

Exercise 5 (Q1-Q4)

Case B: PHP and MySQL is selected

I used the AppServ package that Apache Web server, PHP, MySQL and phpMyAdmin are all included. The detail versions screen is captured below. (ex5_1a)




1. Examine the environment variables on the server (5_1b)




Running result (5_1c)




2. Create a web application called “hello_world.php” (5_2a)




Running result (5_2b)





3. Create an HTML page with the form: (5_3a)




Running result (5_3b)





4. Create a PHP file named “submit.php”- Note the script is not correct, replaced with “$_GET[myname] (5_4a)





Running result (5_b)



(5_4c)


Friday, March 12, 2010

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


I came from a hardware background, so my programming skill is very limited. I have learnt the basic XHTML syntax coding and Dreamweaver CS4 as my only web development tool from the Multimedia programming course.


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 ‘a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.’ (Ruby, n.d.)

Ruby is an interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). It is simple, straight-forward, and extensible. (FreeBSD Man Pages, 2002)

In summary, Ruby is a general purpose Object Oriented Programming Language, it was invented by Yukihiro Matsumoto in mid 90’s. Ruby sees all the information in the programming as objects. He extracted and combined some languages like PERL, Python, Small Talk and Lisp to make up a syntax of codes that is similar to English for easy understanding, and leave the difficult part handled by the language itself. (An interpreted scripting language).

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


While Ruby is a language, Rail is a web application development framework written in Ruby around 2005. The framework is based on Model View Controller (MVC) structure and very good for The Ruby on Rails works together well and helps to gain great popularity.

Commonly appeared, Ruby on Rails (RoR) is a free open source web development framework based on Model-View-Controller that very good for efficient programming (e.g Agile programming) and yet it is powerful as well.


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

Convention over Configuration (CoC) is a software design principle for rapid development; trying to ‘Don’t Repeat Yourself’ (DRY). The paradigm is to reduce the number of specifications by only defining those parameters not nature. For example, ‘if there is a class Sale in the model, the corresponding table in the database is called sales by default. It is only if one deviates from this convention, such as calling the table "products sold", that the developer needs to write code regarding these names. Generally, this leads to less code and less repetition.’ ‘"Don't repeat yourself" means that information is located in a single, unambiguous place. For example, using the ActiveRecord of Rails, the developer does not need to specify database column names in class definitions. Instead, Ruby on Rails can retrieve this information from the database based on the class name.’ (Wiki, 2010)

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

MVC was first described in 1979 by Trygve Reenskaug, then working on Smalltalk at Xerox PARC. The original implementation is described in depth in the influential paper "Applications Programming in Smalltalk-80: How to use Model–View–Controller".

Model–View–Controller (MVC) is a software architecture , currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" (the application logic for the user) from input and presentation (GUI), permitting independent development, testing and maintenance of each. Model–View–Controller (MVC) is a software architecture , currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" (the application logic for the user) from input and presentation (GUI), permitting independent development, testing and maintenance of each.


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

To follow the MVC design, it is required to set up a structure have an isolation between the model (data or database), view (the user interference or presentation) and controller (the application logic). This model can allow isolation development, testing and maintenance.


References


Free BSD Man Pages. (2002). Manual Reference Pages - RUBY(1). Retrieved from http://www.gsp.com/cgi-bin/man.cgi?section=1&topic=ruby on 12 March 2010

Rudy. (n.d.) Home page. Retrieved from http://www.ruby-lang.org/en/ on 12 March 2010

Wiki. (2010). Convention over Configuration. Retrieved from http://en.wikipedia.org/wiki/Convention_over_configuration on 12 March 2010
Wiki. (2010). Model–view–controller. Retrieved from http://en.wikipedia.org/wiki/Model-view-controller#History on 12 March 2010

Thursday, March 11, 2010

Exercise 4

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

The fundamental difference between the two is the approach of operation. The client/ server architecture is a centralized support system, the server in the center provides the data and operation, usually is a higher performance machine, to support the requests from the client computers. The client uses the resources from server but would not share their own resources to others. Typical applications like email, database and web servers where the clients are supported by the central machine.

In the Peer to Peer architecture, there is no central support system. All the computers are on the same operation level; they share and use the resources with others simultaneously. Typical applications like file sharing, Napster. One benefit of the Peer to Peer architecture is the scalability of resources, as more computers join, the resources are scaled up. However, in a client/ server architecture, more clients will reduce the server performance.


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

c. Ruby on Rails
f. AJAX frameworks

Ruby on Rails (RoR), is an open source web application framework for the Ruby programming language., it is an easy to use framework and very suitable for short term development like Agile development methodology.
Ajax (Asynchronous JavaSrcipt and XML) is a group of interrelated web development techniques. The main feature is to create interactive web applications, and it can retrieve the renewed data in the background (Asynchronously) without affecting the front end display.

Exercise 3

1. Explain DNS and DHCP and how does DNS differ fom DHCP configuration?

DNS (Domain Name System)
On the Internet, each computer needs to have an unique address to be located. It’s just like a postal address for an individual. For the computer itself, an IP address consists of 4 bytes (32 bits) of decimals, and separated by dots are used. E.g. 208.77.188.166. These numbers are good for machine, but not good for human to memorize. Therefore, a ‘meaningful’ name called DNS is used to map the IP address to a human memorized-able name. e.g. www.yahoo.com. DNS is a naming system and it is maintained central at Internet Corporation for Assigned Names and Numbers (ICANN).

DHCP (Dynamic Host Configuration Protocol)
DHCP is the computer protocol for the computers to get an IP address when it is connected to the network. The computer needs to be configurated as a DCHP Client and the machine who assign the IP address is called DHCP Server. In case the DHCP Server is not present, or for some reasons a specific computer wants to have a fixed IP address (e.g. a file server) then manually assign the IP address is required. (we call it a static IP address)

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

To have static IP address can have two main benefits: (1) The translation is more effective, so the response for the visitor is better. (2) It is more secure than using a DHCP that might route you to somewhere fake web sites.

3. What role can the following play in business to business e-commerce
a) Virtual Private Network (VPN) or Grid computing services?


The VPN is a method to provide additional security on top of a communication network and make the communication between two ends looks like ‘private’. (or technical term called ‘Tunnel’). The VPN encapsulates the traffic and data to avoid eavesdropping. For e-commerce, VPN improves confidence for monetary transaction like credit card information. So it helps to boost the e-commerce without the fear of losing confidentiality.

b) Next generation of wireless mesh network

First, a wireless mesh network (WMN) can be defined as ‘is a communications network made up of radio nodes organized in a mesh topology. Wireless mesh networks often consist of mesh clients, mesh routers and gateways. The mesh clients are often laptops, cell phones and other wireless devices while the mesh routers forward traffic to and from the gateways which may but need not connect to the Internet.’ (Wiki, 2010).

From a study conducted jointly by Deutsche Telekom Laboratories and University of Napoli, the existing mesh network technology ‘shows the feasibility of providing WiFi coverage to large areas, such as entire cities. But not more. At a technical level, current mesh networks are far from efficient’. (Karrer, P. & Pescape, A., 2009). With the next generation of wireless mesh network, all these areas would be improved. Then more people could access with confidence through the next generation of WMN. Hence the potential e-commerce market would be enlarged.


References


Karrer. P., & Pescape. A. (2009). 2ndgenerationwirelessmeshnetworks: technical, economical and social challenges. Retrieved from http://www.deutsche-telekom-laboratories.de/~karrer/papers/FGCN07.pdf on 11 March 2010

Wiki. (2010). Wireless Mesh Network. Retrieved from http://en.wikipedia.org/wiki/Wireless_mesh_network on 11 March 2010

c) Cloud or Social cloud applications


Cloud applications are the applications that offered by the giant ‘cloud’ service providers like google, amazon and IBM. With the traditional model, a company wants to enter into the e-commerce, they need to set up their own IT department, develop their e-commerce application. But with the cloud applications, they don’t need to start everything from scratch. There are bunches of application and software that can be used right away. With the SaaS concept (Software as a Service), the small or medium company that originally do not have the capability can now easily to deploy e-commerce. Therefore, the Cloud applications would lower the threshold and help more companies join the e-commerce world.

4. If clouding computing is the “black box”, the grid computing is a component as the “white box”


Explain what you interpret about that statement.
Most time we heard about cloud computing are scalability, pay as you use, utility computing…etc. The focus of ‘cloud computing’ is the benefits that can be offered from the service provider like a black box, and the users no longer need to worry how to maintain the IT department.
The grid computing is ‘a form of distributed computing whereby a “super virtual computer” is composed of many networked loosely coupled computers acting in concert to perform very large tasks.’ (Grid Computing, 2010) The grid computing is more on the technology side, so it can be seen a component as the white box of the cloud computing.


References

Wiki. (2010). Grid Computing. Retrieved from http://en.wikipedia.org/wiki/Grid_computing on 11 March 2010

Wednesday, March 10, 2010

Exercise 2

Describe the steps involved with Rapid Evolutionary Prototyping Approach as it applies to developing a Web application. How is it related to agile development?


The Rapid Evolutionary Prototyping Approach (REPA) is one of the Application Development methods. Because it’s simplistic nature, it is very suitable for small to medium business that needs a quick solution.

The REPA basis on repetitive interactions between the developer and the stake holders. The main steps can be divided into 3 steps:

1. Collect customer requirements and define the system design
2. Develop the prototype
3. Testing with customer’s input

The web application can be developed with repeating the steps 1 to 3 again and again until the customer accept the prototype and eventually use the prototype to develop the actual product. Basically it is making the analysis and design work together instead of traditional design like waterfall.

Agile development is similar to REPA as a iterative method, except the time is measured in weeks, not months. So it is more suitable to the small scale jobs.