Elevator Pitch 1 - Text Version
After I have done all the exercise and workshop in assigment1, I could understand how Ruby is good for rapid software application development. It is because...
First, Ruby is used Convention over Configuration in order to lower down the programmer effort, especially reduce the program code.
Second, Ruby supports Automated DB Model Mapping which let the programmer that need not create many connection string to access the DB to do the query, insert, update and delete.
Third, Ruby supports full Stack of MVC Framework, it is well-defined each part of responsibility during web application development and let the code structure be more clearly. In the real case, when I am doing the online taxi booking system, I really think Ruby is very convenience for writing a program in an easy mode, for example,
In ruby, I can use rake to create the table in mysql when the db schema has been pre-defined,
moreover, I can call the data from mysql in anywhere of my web application.
Also, I can use scaffolding to generate program codes dynamically which follows with the CRUD schema. Therefore, I just need to edit the View file for my web application to build up the interface and add the validation code for user input only.
That's all. Honestly, Ruby increases the productivity of web application development.
=============================================================
The audio version of elevator pitch which has 220 words within 2mins has been uploaded to EASTS.
4/15/2009
4/14/2009
FocusGroup1
1. Share my encountered problem and soluton during use of Ruby and Rails.
a.) ERROR 1045 (28000): Access denied for user '-root'@'localhost' (using password:NO)
When the web application connect to mysql database, it prompts out an error "ERROR 1045 (28000): Access denied for user '-root'@'localhost' (using password:NO)"
Solution: Use phpmyadmin to change the root password.
b.) Undefined method 'scaffold' for TaxiController:Class
When i am using scaffold in my Taxi Controller [scaffold :taxi]]to dynamic generate the web application, i encounter an issue that is undefined method 'scaffold' for Taxicontroller:class.
Solution: Install the scaffolding plugin by issuing the command "plugin install scaffolding"
c.) Undefined method 'paginate' for # TaxiController
After i have successfully installed the scaffold plugin, i re-run the taxi web application in the browser, i encounter an issue that is undefined method 'paginate' for # TaxiController
so, i search the plugin from web in order to install that plugin...But..
after issuing the command : ruby script/plugin install http://tools.assembla.com/svn/breakout/breakout/vender/plugins/classic_pagination,
that plugin still does not install properly as the classic_pagination in taxiapp\vendor\plugins\classic_pagination is an empty directory.
Solution: Download classic_pagination plugin in my pc and extract it in
"vendor\plugins\classic_pagination" under the taxi web application.
d.) Web application interface design issue
It is difficult for us to build up a professional interface within a limited time using html editor.
Solution: Download a dreamweaver plugin named rubyweaver in order to let dreameaver support rhtml format from http://rubyweaver.gilluminate.com/download.
e.) Time is in long format after querying from mysql
Background: In workshop 3, I define a column named time_required in mysql with the datatype that is time, when i use ruby to get resultset of that records, i find that the time_required value is in long time format like "Sat Jan 01 02:05:40 +0800 2000"
Solution: use strftime to get the hour and minute in order to control the timeformat, for example, passenger.time_required.strftime("%I:%M%p")
f.) JobID does not be auto-increment during the table altering.
Backgroud: In workshop 3, I need to create JobID with auto-increment manner, when i alter that column attribute, mysql does not allow JobID being auto-increment, it is because the column named ID already be auto- increment, it does not allow 1 table having 2 columns that is using auto-increment.
Solution: Create a JobID generator which will automatically plus one after getting the last recordset of JOBID, for example
a.) ERROR 1045 (28000): Access denied for user '-root'@'localhost' (using password:NO)
When the web application connect to mysql database, it prompts out an error "ERROR 1045 (28000): Access denied for user '-root'@'localhost' (using password:NO)"
Solution: Use phpmyadmin to change the root password.
b.) Undefined method 'scaffold' for TaxiController:Class
When i am using scaffold in my Taxi Controller [scaffold :taxi]]to dynamic generate the web application, i encounter an issue that is undefined method 'scaffold' for Taxicontroller:class.
Solution: Install the scaffolding plugin by issuing the command "plugin install scaffolding"
c.) Undefined method 'paginate' for #
After i have successfully installed the scaffold plugin, i re-run the taxi web application in the browser, i encounter an issue that is undefined method 'paginate' for # TaxiController
so, i search the plugin from web in order to install that plugin...But..
after issuing the command : ruby script/plugin install http://tools.assembla.com/svn/breakout/breakout/vender/plugins/classic_pagination,
that plugin still does not install properly as the classic_pagination in taxiapp\vendor\plugins\classic_pagination is an empty directory.
Solution: Download classic_pagination plugin in my pc and extract it in
"vendor\plugins\classic_pagination" under the taxi web application.
Solution: use strftime to get the hour and minute in order to control the timeformat, for example, passenger.time_required.strftime("%I:%M%p")
f.) JobID does not be auto-increment during the table altering.
Workshop 4-part 2
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.
a.) Create a ruby file named dognames with the following code:

Code Explanation:
First, create a method name dogname.
Second, print out a message to ask user for imput three dog names and store the standard input to the variable named dogA, dogB and dogC.
Third, create three varibale which declare null is used to store the order of dog name, they are named first, second and third.
Fourth, use if-elseif-else statement to sort dog name order, if the result is -1, that means the front variable is smaller, for exampe, (a <=> b)==-1.
Fifth, print out the order of the dog name and end the dogname method.
Sixth, execute dogname method.
b.) Execute the dognames.rb by issuing the command "ruby dognames.rb", and the result is showed as below screen dump.

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".
a.) Create a ruby file named fizzbuzz with the following code:
Code Explanation:
First, declare a variable named num and set the value to 1,
Second, use while-loop to control the looping between 1 to 100
Third, use if-elseif-else statement to set the conditon, if multiples of three print "Fizz" instead of the number, multiples of five print "Buzz" and multiples of both three and five print "FizzBuzz".
Fourth, num will plus 1 per each looping.
b.) Execute the fizzbuzz .rb by issuing the command "ruby fizzbuzz .rb", and the result is showed as below screen dump.

3.Compare the Ruby and Python versions of the dog years calculator:
#!/usr/bin/ruby
# The Dog year calculator program called dogyears.rb
def dogyears
# get the original age
puts “Enter your age (in human years): "
age = gets # gets is a method for input from keyboard
puts # is a method or operator for screen output
#do some range checking, then print result
if age <> 110
puts "Frankly, I don't believe you."
else
puts "That's", age*7, "in dog years."
end
dogyears
Python
#!/usr/bin/python
# The Dog year calculator program called dogyears.py
def dogyears():
# get the original age
age = input("Enter your age (in human years): ")
print # print a blank line
# do some range checking, then print result
if age <> 110:
print "Frankly, I don't believe you."
else:
print "That's", age*7, "in dog years."
### pause for Return key (so window doesn't disappear)
raw_input('press Return>')
def main():
dogyears()
main()
===========================================
There are some different codes syntax between Ruby and Pythob which are listed in the following
1.Getting standard Input Ruby uses get, but Python uses input
2. Printing out the messageRuby uses puts, but Python uses print
3.The syntax of if-statement is differenta.)Ruby does not need the symbol -> “:” after the if-conditonal, but Python needsb.) Ruby uses “elsif” in if-elseif-else statement, but Python uses elif.
4.)Ruby does not need call the method in the main(), but Python needs.
In the dogyear program, actually, both of them do the same thing that get the input from console and verify the input integer whether is smaller than zero, if yes , print out “Negative age?!? I don't think so” if no, verify it whether is smaller than 3 and older than 110, if yes, print out “Frankly, I don't believe you.”, and finally, if all condition is not true, it let the input integer times 7 and print out "That's", then print out the value of input integer which has been already timed 7 and finally print out "in dog years."
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.
a.) Create a ruby file named dognames with the following code:

Code Explanation:
First, create a method name dogname.
Second, print out a message to ask user for imput three dog names and store the standard input to the variable named dogA, dogB and dogC.
Third, create three varibale which declare null is used to store the order of dog name, they are named first, second and third.
Fourth, use if-elseif-else statement to sort dog name order, if the result is -1, that means the front variable is smaller, for exampe, (a <=> b)==-1.
Fifth, print out the order of the dog name and end the dogname method.
Sixth, execute dogname method.
b.) Execute the dognames.rb by issuing the command "ruby dognames.rb", and the result is showed as below screen dump.

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".
a.) Create a ruby file named fizzbuzz with the following code:

Code Explanation:
First, declare a variable named num and set the value to 1,
Second, use while-loop to control the looping between 1 to 100
Third, use if-elseif-else statement to set the conditon, if multiples of three print "Fizz" instead of the number, multiples of five print "Buzz" and multiples of both three and five print "FizzBuzz".
Fourth, num will plus 1 per each looping.
b.) Execute the fizzbuzz .rb by issuing the command "ruby fizzbuzz .rb", and the result is showed as below screen dump.

3.Compare the Ruby and Python versions of the dog years calculator:
#!/usr/bin/ruby
# The Dog year calculator program called dogyears.rb
def dogyears
# get the original age
puts “Enter your age (in human years): "
age = gets # gets is a method for input from keyboard
puts # is a method or operator for screen output
#do some range checking, then print result
if age <> 110
puts "Frankly, I don't believe you."
else
puts "That's", age*7, "in dog years."
end
dogyears
Python
#!/usr/bin/python
# The Dog year calculator program called dogyears.py
def dogyears():
# get the original age
age = input("Enter your age (in human years): ")
print # print a blank line
# do some range checking, then print result
if age <> 110:
print "Frankly, I don't believe you."
else:
print "That's", age*7, "in dog years."
### pause for Return key (so window doesn't disappear)
raw_input('press Return>')
def main():
dogyears()
main()
===========================================
There are some different codes syntax between Ruby and Pythob which are listed in the following
1.Getting standard Input Ruby uses get, but Python uses input
2. Printing out the messageRuby uses puts, but Python uses print
3.The syntax of if-statement is differenta.)Ruby does not need the symbol -> “:” after the if-conditonal, but Python needsb.) Ruby uses “elsif” in if-elseif-else statement, but Python uses elif.
4.)Ruby does not need call the method in the main(), but Python needs.
In the dogyear program, actually, both of them do the same thing that get the input from console and verify the input integer whether is smaller than zero, if yes , print out “Negative age?!? I don't think so” if no, verify it whether is smaller than 3 and older than 110, if yes, print out “Frankly, I don't believe you.”, and finally, if all condition is not true, it let the input integer times 7 and print out "That's", then print out the value of input integer which has been already timed 7 and finally print out "in dog years."
訂閱:
文章 (Atom)