Friday, April 16, 2010

Workshop 3


Downloading MySQL:-
1. Go to http://www.mysql.com/downloads/workbench/
2. Click on download and avoid login by clicking "No thanks “message just below the login in form.
3. This is the file which we have to download mysql-workbench-oss-5.1.18a-win32.msi   
During installation I got error and I try lots of solve it but I couldn’t. I went through all websites about this matter. But I will sort out and will post here later on.

2. Once Rails is running at http://localhost:3000, you need to configure database access.
To start the internal webserver of WEBrick easy to use.We have to run a command prompt from winows and browse top directory of new web application 
 
Going to http://localhost:3000/ in Firefox Web browser, shows this form which means the WEBrick webserver is operational and ruby is working correctly.

Workshop 4

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.
This is my first Ruby program dognames.rb. I use Ruby interpreter (irb.bat) for test and debug the Ruby program. And then run the program from the console window using either C:\ruby dogname.rb.
def dognames
  puts "Whats your dog name: "
  $dog1 = gets

  puts "Whats your dog name: "
  $dog2 = gets

  puts "Whats your dog name: "
  $dog3 = gets
array = [$dog1,$dog2,$dog3]
puts "your dog name"
puts array.sort


dognames
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“.
This is my Fizzbuzz program fizzbuzz.rb.
def FizzBuzz

  1.upto(100) do |i|
    if i % 5 == 0 and i % 3 == 0
      puts "FizzBuzz"
    elsif i % 5 == 0
      puts "Buzz"
    elsif i % 3 == 0
      puts "Fizz"
    else
      puts i
    end
  end
end
fizzbuzz

Workshop 2


1. How is Rails structured to follow the MVC pattern?
The Ruby on Rail deals with Model-View-Controller (MVC) framework. The benefits of MVC are isolation of business logic from the user interface, ease of keeping code DRY “Don’t Repeat Yourself “and making it clear where different types of code  belong for easier maintenance.
To know the clearly understand about MVC pattern. We create an application called Blog. We create this by using this command C:\ruby\> rails Blog.
After that two view the root directory steps as follows:-
C:\ruby\> rails Blog.
C:\ruby\> cd blog
C:\ruby\blog> dir
And the directory structure is as follows:-


C:\ruby\blog\app>dir



Models
A model is an object representing data or even activity, e.g. a database table or even some plant-floor production-machine process
.
View
View is some form of visualization of the state of the model.  In Rails, views are often HTML files with embedded Ruby code that performs tasks related solely to the presentation of the data. Views handle the job of providing data to the web browser or other tool that is used to make requests from your application.

Controllers
A controller offers facilities to change the state of the model. In Rails, controllers are responsible for processing the incoming requests from the web browser, interrogating the models for data, and passing that data on to the views for presentation.



2. Apply the MVC design approach to our Project: Online Taxi Booking System.

The model is of a Ruby class to be found in app/models/passenger.rb. The SQL table is passengers – the pluralisation of the model.

The controller method located in app/controllers/passenger_controller.rb. Each controller can access templates to display the input screen and methods for action.

The views are set aside in app/views/passenger/*.rhtml, where each *.rhtml maps to a controller method.

 
 

Exercise 7

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

    - Increasing business efficiency and competitiveness
    - Improving customer satisfaction
    - Improving IT operational efficiency
     - Increasing reuse of existing applications "web1"

2.What is the relationship of AJAX to JQuery and the lightweight web 2.0 javascript framework called MooTools within the enterprises software architecture?
Answer:- 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 to write JavaScript.
      MooTools is a compact, modular, Object-Oriented  JavaScript framework designed for the intermediate to advanced JavaScript developer. It allows you to write powerful, flexible, and cross-browser code with its elegant, well documented, and coherent API.

3.What are the similarities between the object-oriented development using model-view-controller(MVC) in Rub on Rails 2.0. And action script 2.0(Flash animations)?
Answer:-
Model–View–Controller (MVC) is a software architecture, currently considered as an architectural pattern used in software engineering.The Model View Controller principle divides the work of an application into three separate but closely cooperative subsystems.
     The close simliraties MVC in Ruby on Rail 2.0 and Action Script 2.0 is both of them are used for  object-oriented development using MVC, however Ruby on Rails is for Website and application development while the ActionScript is dedicated for a specific environment - Flash animations.

4.What does it mean to develop RESTful practices into our web application?
Answer:-

The REST  stand for Representational State Transfer. architectural style for web applications was first put forward by Roy Thomas Fielding  in 2000, but in its essence it's a rediscovery of the merits of the good old HTT  protocol. JSF applications, though, normally don't conform to the HTTP  specification at all.

The basic principles of the HTTP are:

   1. HTTP is stateless.
   2. Each resource
   3.Resources are being accessed via specific verbs, each of which designates the type of the requested interaction with the resource:
         1.GET for displaying a resource
         2.POST for creating a resource
         3. PUT for modifying a resource
         4.DELETE for deleting a resource
   4.The resources can be requested in specific content types, as needed on the client.

RESTful web applications conform to these principles, it guaranteeing uniform access to resources regardless of their location, enabling easy integration and loose coupling between applications. Building on that, RESTful web applications make it easy to provide device-specific responses and search engine optimized URLs. "weba"

Reference:-
"web1" http://itc594hochiman.wordpress.com/2010/03/24/exercise-7-user-input-for-database-access-with-php/
"weba"  http://jsf-spring.sourceforge.net/reference/ch04.html

Wednesday, April 14, 2010

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.



Reference:-
http://w3schools.com/xml/xml_tree.asp

Tuesday, April 13, 2010

Exercise 6: Web form Design and Processing

1. design the form
 "retrofit' the form data string above
name=Evan+Burke&card=Visa&number=8443261344895544&order=French+perfume
for  buying some French perfume into the HTML form fields and submit button on the web page form.
Coding:-



Output:-

 

Workshop 1 - Setting up the model railway


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 did some basic programming language during my Bachelor degree like C, C++, visual basic, Java and mysql but it has been long before but I have little knowledge and understand how the program works and execute. About web development tools I am using HTML and designing software like Photoshop CS2.Now in this semester I am doing XML also.
 Web application framework is the software framework that is designed to maintain the development of dynamic websites, Web applications and Web services.

Ruby is “an interpreted scripting language” for quick and easy object-oriented programming”. Find out about the Ruby language and discover what this means.
The programs are usually written in high level code which the CPU cannot execute. So this source code has to be converted into machine code through interpreter. An interpreter naturally converts it every time a program is executed.”Wiki1”

Ruby is also called object oriented programme because every data type is an object including class and types which’s many other languages designate as primitives such as integer, Booleans and nil. And every function is a method. “Wiki2”

What is Rails and how does it work with Ruby?
Rails can be defined as the framework which provides a variety of programs which perform most of the application segment. This makes the programming tasks much simpler and easier. And follow the same pattern as any other programming framework. These frameworks when implemented ease up the take of the programmer as it reduces a large amount of code writing.
Ruby is the base foundation for Rails. Thus it is correct to state that they have a parent/child relationship with each other; Ruby is the parent and Rail is the child.
Ruby helps a programmer to be a better developer by giving him a better understanding of the code he is working with. It makes programming easier as the developer is familiar with the readily available idioms and conventions of Ruby. Knowledge of Ruby also makes debugging quite an easy task for the programmer when he is working with Rails.
Compared to the other programming languages and development environments, Ruby on Rails is a very efficient way of developing successful web applications in a shorter time.
What is meant by “convention over configuration” in regards to the use of Rails in Web application development?
Convention over Configuration is a software design paradigm used by Rails in web application development which seeks to decrease the number of decisions that developers need to make, gaining simplicity, but not necessarily losing flexibility.

When did Model-View-Controller begin and where is it used?
The model is the domain-specific representation of the data upon which the application operates. Domain logic adds meaning to raw data (for example, calculating whether today is the user's birthday, or the totals, taxes, and shipping charges for shopping cart items).
The view renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes.
The controller receives input and initiates a response by making calls on model objects. An MVC application may be a collection of model/view/controller triplets, each responsible for a different UI element.
MVC is often seen in web applications where the view is the HTML or XHTML generated by the app. The controller receives GET or POST input and decides what to do with it, handing over to domain objects (i.e. the model) that contain the business rules and know how to carry out specific tasks such as processing a new subscription. “wiki4”

Describe the steps involved with the MVC design approach.
  1. The user interacts with the user interface in some way such as click a mouse button.
  2. The controller handles the input event from the user interface, and converts the event into appropriate user action, understandable for the model.
  3. The controller notifies the model of the user action, possibly resulting in a change in the model's state. (
  4. A view queries the model in order to generate an appropriate user interface
  5. The user interface waits for further user interactions, which restarts the cycle. “wiki5”

Reference:-
Wiki1”http://en.wikipedia.org/wiki/Interpreter_%28computing%29
"Wiki2" http://en.wikipedia.org/wiki/Ruby_%28programming_language%29
“Wiki3”http://www.meshplex.org/wiki/Ruby/Ruby_on_Rails_programming_tutorials
“wiki4”http://en.wikipedia.org/wiki/Model_view_controller
“Wiki5”http://en.wikipedia.org/wiki/Model_view_controller

Monday, April 12, 2010

Exercise 5


CASE B: PHP and Mysql
I used XAMPP control panel that Apache Web server, PHP, MySQL and phpMyAdmin are all included. The below snapshot is the one which i used.

2.Create a web application called "hellow-world.php"which contains in the body:
Code is:
Output of above code:
 

3.Create an HTML page with the form
Code:-

Output of above code:-


4.The code given on study guide is not working.I tried lots.At last i did in this way and it works.
Code:-


Combination of Q.3 and Q.4 output :-


5.b. This is how we can add a record and is part of a file to create called add_record.html
Coding:-
Output:-


5.c the corresponding PHP files is add_record.php used with the post method.
Coding:-

Saturday, April 3, 2010

Exercise 4

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

A peer-to-peer computing play the responsibility of both server and client, here every client may request and share resources to other clients. All computers are connecting each other without any server. The total capacity of the system will increase as per the nodes increase and the  distributed nature of P2P networks also increases robustness, and in pure P2P systems by enabling peers to find the data without relying on a centralized index servern and there is no single point of failure in the system.

When the term peer-to-peer was used to describe the Napster network, it implied that the peer protocol was important, but, in reality, the great achievement of Napster was the empowerment of the peers (i.e., the fringes of the network) in association with a central index, which made it fast and efficient to locate available content. The peer protocol was just a common way to achieve this.

Client-server computing or networking is a distributed application architecture that partitions tasks or workloads between service provider’s server and service requester, called clients. A Server machine is a high-performance host that is running one or more server programs which share its resources with clients. A client does not share any of its resources, but requests a server's content or service function.

 Here all data is stored on the servers, which generally have far greater security controls than most clients, server can better control and appropriate permissions given to each clients to access resources. And all data are storage in server; updates to that data are far easier and faster. It functions with multiple different clients of different capabilities.

Reference:-
http://en.wikipedia.org/wiki/Peer-to-peer
http://en.wikipedia.org/wiki/Client-server


2.Frameworks for development.Compare and contrast between Java and .Net.
Answer:-
Java is an open source programming language developed by Sun Microsystems while the .net is a programming infrastructure created by Microsoft for building, deploying and running application and services that use .net technologies, such as desktop application and web services
Java is portability, which means that computer programs written in the Java language must run similarly on any supported hardware/operating-system platform. And .NET applications will run only on Windows. But both environments are platform independent.
 Both environments include OO features such as polymorphism, encapsulation, and inheritance. Both languages are compiled, Java into byte code and .NET languages into Intermediate Language.

Reference:-
http://en.wikipedia.org/wiki/Java_(programming_language)
http://www.online-brain.com/blogs/java_dotnet