SlideShare uma empresa Scribd logo
1 de 56
Baixar para ler offline
Ruby on Rails 探索
      kewang
Agenda
●   What is Ruby?
●   What is Rails?
●   Live DEMO
●   FAQ
●   Q&A




                              2
What is Ruby?
 鑽石恆久遠,一顆就破產




                3
What is Ruby?

●
    開放原碼、物件導向的動態直譯式程式語言
●
    簡單哲學、高生產力
●
    精巧、自然的語法
●
    靈感來自 Lisp, Perl, Smalltalk
●
    設計的目的是要讓程式設計師 Happy



                                 4
Matz 說
●
    一般程式語言的開發目的
    ●
        可寫出能夠高速運作的程式
    ●
        可在短期間學會寫程式
    ●
        寫一次到處都能跑
    ●
        小朋友也能輕易寫出程式




                        5
但主張「讓寫程式更快樂」的語言卻不太常見




                   6
Matz




Ruby is simple in appearance, but is very
complex inside, just like our human body.




                                            7
Programming Language Type
●   Dynamic Strong Language
    ●   Ruby
    ●   Perl
    ●   Python
●   PHP is Dynamic, but is not Strong.
●   Java is Strong, but is not Dynamic.




                                          8
EVERYTHING IS OBJECT




                       9
irb – Interactive Ruby




                         10
TIOBE Ranking




                11
Features
●   Iterator
●   Code block (closure)
●   ! and ?
●   Meta-programming




                                12
Iterator
●
    重複做多次類似的事情
●   upto, downto, step, times, collect, map, each_*,
    *_each, sort...many methods




                                                       13
Code block (closure)




                       14
Code block (closure)




                       15
Code block (closure)




                       16
Code block (closure)




                       17
! and ?
●   ! means side-effect
●   ? means return Boolean




                                    18
! and ?




          19
Meta-programming




                   20
RubyGems
●
    Ruby 的套件管理工具
●
    所有的 Ruby 套件都可以用 gem 安裝
    ●   Rails
    ●   RMagick
    ●   Heroku
    ●   ...etc.
●   http://rubygems.org


                              21
Sinatra
●   It's a VERY lightweight web development package
●   gem install sinatra
●   http://www.sinatrarb.com




                                                      22
Hello Sinatra
●   ruby myapp.rb, and open http://localhost:4567




                                                    23
Hello Parameter




                  24
Sinatra - XDite 如是說

    使用 Sinatra 的目的並不是用來開發那些巨型
    的 Web application ,而是搭造那些小型的應
    用程式或者 API 介面。這樣做有些什麼好處
    呢?

    如果你只是想寫一支小型程式,或者開發
    API ,並不需要使用 Rails 這麼複雜 ( 或肥 )
    的 Framework 做這些簡單的事。使用 Sinatra
    既簡單, Respond 也迅速。



                                     25
What is Rails?
   火車環島正夯




                 26
What is Rails?
●   It's a Web Framework




                                 27
What is Rails?




                 28
What is Rails?

      ●   DHH
      ●
          從 37signals 公司的專案
          管理工具 Basecamp 裡面
          分離出 Ruby on Rails
      ●
          2005 年獲得年度最佳
          Hacker



                              29
What is Rails?
●
    正式名稱 Ruby on Rails
●
    使用 MVC(Model-View-Control)
●
    內建 unit / integration test
●
    支援 Ajax, RESTfFul, ORM
●
    支援最新技術 HTML5, jQuery, SASS, HAML, Coffee
    Script



                                           30
Design Principles




       DRY
Don't Repeat Yourself



                        31
Design Principles




           CoC
Convention over Configuration



                            32
Rails is so FAST!!!

                 JSP            Rails

            4 個月,每週約 20   4 個晚上,每晚 5 小
 交貨時間
            小時            時

 程式碼行數          3293           1164

 設定檔行數          1161            113

類別數 / 方法數       62/549         55/126

                                        33
What is MVC




              34
What is MVC
●
    Model 包裝了資料與商業邏輯,例如操作資料庫
●
    View 表示使用者介面,顯示及編輯表單
●
    Controller 將資料送進送出 Model ,處理從外界
    來的 HTTP Request ,與 Model 互動後輸出至
    View




                                      35
DB schema




            36
ActiveRecord (M)




                   37
Rails console




                38
Rails console




                39
ActionController (C)




                       40
ActionView (V)




                 41
What is URL routing?




                       42
a bloated controller
             class EventController < ApplicationController

index                       /events/index

show                        /events/show/1

new                         /events/new

create                      /events/create

show_comment                /events/3/show_comment/6

mark_spamcomment            /events/7/mark_spamcomment/5

add_favorite                /events/2/add_favorite

invite                      /events/1/invite

deny_user                   /events/1/deny_user/13

allow_user                  /events/2/allow_user/27


                                                             43
What is RESTful?
    before              after      ActionController
/events/create     POST /events    events#create


/events/show/1     GET /events/1   events#show


/events/update/1   PUT /events/1   events#update


/events/destroy/1 DELETE /events/1 events#destroy



                                                    44
Let's modify bloated controller
               class EventController < ApplicationController

index              GET /events                     events#index

show               GET /events/1                   events#show

new                GET /events/new                 events#new

create             POST /events                    events#create

show_comment       GET /events/3/comments/6        event_comments#show

mark_spamcomment PUT /events/7/comments/5/spam     event_comments#spam

add_favorite       POST /events/2/favorite         events#favorite

invite             POST /events/1/invite           events#invite

deny_user          PUT /events/1/users/13/deny     event_users#deny

allow_user         PUT /events/2/users/27/allow    event_users#allow


                                                                       45
RESTful routing
HTTP Verb        Path                action
GET         /photos          index
GET         /photos/new      new
POST        /photos          create
GET         /photos/:id      show
GET         /photos/:id/edit edit
PUT         /photos/:id      update
DELETE      /photos/:id      destroy


                                              46
One action, multiple formats




                               47
One action, multiple formats




                               48
Live DEMO
...Never Live DEMO




                     49
FAQ
Fxxk you!?




             50
Why Ruby?
●   Domain-specific language
●   Full object-oriented programming
●   High usability
●   High readability, maintenance




                                       51
Why Rails?
●   The most successful Web Framework
●   Imitation is the greatest compliment
    ●   CakePHP
    ●   Grails
    ●   TurboGears
    ●   catalyst




                                           52
Websites




           53
Performance Comparison

             PHP 5.2.3


           Python 2.5.1
                                                                        Lines of Code
                                                                        Time per iteration
Language




            Ruby 1.9.0                                                  (microseconds)


             C++ 4.2.3


               Java 1.6

                          0   100   200   300   400   500   600   700
                                                                                     54
                                           愈小愈好
Performance is slow?
●
    如果一個框架可以讓你僅變快 20% ,或許你應該
    繼續使用比較保險的語言,像是 Java 。但是如果
    你可以變快 300% 甚至更高,那麼其他的差異都
    變的不重要了 from Beyond Java




                               55
Q&A
Quick Asleep




               56

Mais conteúdo relacionado

Mais procurados

GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22Jorge Hidalgo
 
RubyならMacでしょう
RubyならMacでしょうRubyならMacでしょう
RubyならMacでしょうvincentisambart
 
Venkat Subramaniam Blending Java With Dynamic Languages
Venkat Subramaniam Blending Java With Dynamic LanguagesVenkat Subramaniam Blending Java With Dynamic Languages
Venkat Subramaniam Blending Java With Dynamic Languagesdeimos
 
Rubinius - Ruby Implemented with Ruby
Rubinius - Ruby Implemented with RubyRubinius - Ruby Implemented with Ruby
Rubinius - Ruby Implemented with RubyAkanksha Agrawal
 
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOULucas Jellema
 
GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18Jorge Hidalgo
 
"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012
"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012
"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012Blend Interactive
 
Groovy shell scripting
Groovy shell scriptingGroovy shell scripting
Groovy shell scriptingGeorg Berky
 
MacRuby For Ruby Developers
MacRuby For Ruby DevelopersMacRuby For Ruby Developers
MacRuby For Ruby DevelopersRenzo Borgatti
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?Joshua Ballanco
 
eXo EC - Groovy Programming Language
eXo EC - Groovy Programming LanguageeXo EC - Groovy Programming Language
eXo EC - Groovy Programming LanguageHoat Le
 
GraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster EverywhereGraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster EverywhereJ On The Beach
 
Introduzione a macruby
Introduzione a macrubyIntroduzione a macruby
Introduzione a macrubyRenzo Borgatti
 
Esoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in RubyEsoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in Rubymametter
 
Creando microservicios con java micro profile y tomee - CUNORI 2020
Creando microservicios con java micro profile y tomee - CUNORI 2020Creando microservicios con java micro profile y tomee - CUNORI 2020
Creando microservicios con java micro profile y tomee - CUNORI 2020César Hernández
 

Mais procurados (17)

GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22
 
RubyならMacでしょう
RubyならMacでしょうRubyならMacでしょう
RubyならMacでしょう
 
Venkat Subramaniam Blending Java With Dynamic Languages
Venkat Subramaniam Blending Java With Dynamic LanguagesVenkat Subramaniam Blending Java With Dynamic Languages
Venkat Subramaniam Blending Java With Dynamic Languages
 
Rubinius - Ruby Implemented with Ruby
Rubinius - Ruby Implemented with RubyRubinius - Ruby Implemented with Ruby
Rubinius - Ruby Implemented with Ruby
 
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
 
GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18
 
"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012
"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012
"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012
 
APIs Rest com NodeJS
APIs Rest com NodeJS APIs Rest com NodeJS
APIs Rest com NodeJS
 
Polyglot OSGi
Polyglot OSGiPolyglot OSGi
Polyglot OSGi
 
Groovy shell scripting
Groovy shell scriptingGroovy shell scripting
Groovy shell scripting
 
MacRuby For Ruby Developers
MacRuby For Ruby DevelopersMacRuby For Ruby Developers
MacRuby For Ruby Developers
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?
 
eXo EC - Groovy Programming Language
eXo EC - Groovy Programming LanguageeXo EC - Groovy Programming Language
eXo EC - Groovy Programming Language
 
GraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster EverywhereGraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster Everywhere
 
Introduzione a macruby
Introduzione a macrubyIntroduzione a macruby
Introduzione a macruby
 
Esoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in RubyEsoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in Ruby
 
Creando microservicios con java micro profile y tomee - CUNORI 2020
Creando microservicios con java micro profile y tomee - CUNORI 2020Creando microservicios con java micro profile y tomee - CUNORI 2020
Creando microservicios con java micro profile y tomee - CUNORI 2020
 

Semelhante a Ruby on rails探索

Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Coursepeter_marklund
 
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT CompilationHighly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT CompilationMatthew Gaudet
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09Michael Neale
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLBarry Jones
 
An introduction-to-ruby-on-rails
An introduction-to-ruby-on-railsAn introduction-to-ruby-on-rails
An introduction-to-ruby-on-railsvinicorp
 
An Introduction to Ruby on Rails 20100506
An Introduction to Ruby on Rails 20100506An Introduction to Ruby on Rails 20100506
An Introduction to Ruby on Rails 20100506Vu Hung Nguyen
 
Кирилл Толкачев. Микросервисы: огонь, вода и девопс
Кирилл Толкачев. Микросервисы: огонь, вода и девопсКирилл Толкачев. Микросервисы: огонь, вода и девопс
Кирилл Толкачев. Микросервисы: огонь, вода и девопсScrumTrek
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Nilesh Panchal
 
Rich Ajax Platform - theEdge 2012 conference presentation
Rich Ajax Platform - theEdge 2012 conference presentationRich Ajax Platform - theEdge 2012 conference presentation
Rich Ajax Platform - theEdge 2012 conference presentationNicko Borodachuk
 
Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHPMarcos Quesada
 
Devoxx%202008%20Tutorial
Devoxx%202008%20TutorialDevoxx%202008%20Tutorial
Devoxx%202008%20Tutorialtutorialsruby
 
Devoxx%202008%20Tutorial
Devoxx%202008%20TutorialDevoxx%202008%20Tutorial
Devoxx%202008%20Tutorialtutorialsruby
 
JRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVMJRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVMRaimonds Simanovskis
 
Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Wen-Tien Chang
 
mRuby - Powerful Software for Embedded System Development
mRuby - Powerful Software for Embedded System DevelopmentmRuby - Powerful Software for Embedded System Development
mRuby - Powerful Software for Embedded System DevelopmentKazuhiro Koga 古賀一博
 
Make your app idea a reality with Ruby On Rails
Make your app idea a reality with Ruby On RailsMake your app idea a reality with Ruby On Rails
Make your app idea a reality with Ruby On RailsNataly Tkachuk
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overviewjonkinney
 

Semelhante a Ruby on rails探索 (20)

Real World Technologies
Real World TechnologiesReal World Technologies
Real World Technologies
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT CompilationHighly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
From Perl To Elixir
From Perl To ElixirFrom Perl To Elixir
From Perl To Elixir
 
An introduction-to-ruby-on-rails
An introduction-to-ruby-on-railsAn introduction-to-ruby-on-rails
An introduction-to-ruby-on-rails
 
An Introduction to Ruby on Rails 20100506
An Introduction to Ruby on Rails 20100506An Introduction to Ruby on Rails 20100506
An Introduction to Ruby on Rails 20100506
 
Кирилл Толкачев. Микросервисы: огонь, вода и девопс
Кирилл Толкачев. Микросервисы: огонь, вода и девопсКирилл Толкачев. Микросервисы: огонь, вода и девопс
Кирилл Толкачев. Микросервисы: огонь, вода и девопс
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
 
Rich Ajax Platform - theEdge 2012 conference presentation
Rich Ajax Platform - theEdge 2012 conference presentationRich Ajax Platform - theEdge 2012 conference presentation
Rich Ajax Platform - theEdge 2012 conference presentation
 
Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHP
 
Devoxx%202008%20Tutorial
Devoxx%202008%20TutorialDevoxx%202008%20Tutorial
Devoxx%202008%20Tutorial
 
Devoxx%202008%20Tutorial
Devoxx%202008%20TutorialDevoxx%202008%20Tutorial
Devoxx%202008%20Tutorial
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
JRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVMJRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVM
 
Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門
 
mRuby - Powerful Software for Embedded System Development
mRuby - Powerful Software for Embedded System DevelopmentmRuby - Powerful Software for Embedded System Development
mRuby - Powerful Software for Embedded System Development
 
Make your app idea a reality with Ruby On Rails
Make your app idea a reality with Ruby On RailsMake your app idea a reality with Ruby On Rails
Make your app idea a reality with Ruby On Rails
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overview
 

Mais de Mu Chun Wang

如何在有限資源下實現十年的後端服務演進
如何在有限資源下實現十年的後端服務演進如何在有限資源下實現十年的後端服務演進
如何在有限資源下實現十年的後端服務演進Mu Chun Wang
 
深入淺出 autocomplete
深入淺出 autocomplete深入淺出 autocomplete
深入淺出 autocompleteMu Chun Wang
 
你畢業後要任職的軟體業到底都在做些什麼事
你畢業後要任職的軟體業到底都在做些什麼事你畢業後要任職的軟體業到底都在做些什麼事
你畢業後要任職的軟體業到底都在做些什麼事Mu Chun Wang
 
網路服務就是一連串搜尋的集合體
網路服務就是一連串搜尋的集合體網路服務就是一連串搜尋的集合體
網路服務就是一連串搜尋的集合體Mu Chun Wang
 
老司機帶你上手 PostgreSQL 關聯式資料庫系統
老司機帶你上手 PostgreSQL 關聯式資料庫系統老司機帶你上手 PostgreSQL 關聯式資料庫系統
老司機帶你上手 PostgreSQL 關聯式資料庫系統Mu Chun Wang
 
使用 PostgreSQL 及 MongoDB 從零開始建置社群必備的按讚追蹤功能
使用 PostgreSQL 及 MongoDB 從零開始建置社群必備的按讚追蹤功能使用 PostgreSQL 及 MongoDB 從零開始建置社群必備的按讚追蹤功能
使用 PostgreSQL 及 MongoDB 從零開始建置社群必備的按讚追蹤功能Mu Chun Wang
 
Funliday 新創生活甘苦談
Funliday 新創生活甘苦談Funliday 新創生活甘苦談
Funliday 新創生活甘苦談Mu Chun Wang
 
大解密!用 PostgreSQL 提升 350 倍的 Funliday 推薦景點計算速度
大解密!用 PostgreSQL 提升 350 倍的 Funliday 推薦景點計算速度大解密!用 PostgreSQL 提升 350 倍的 Funliday 推薦景點計算速度
大解密!用 PostgreSQL 提升 350 倍的 Funliday 推薦景點計算速度Mu Chun Wang
 
如何使用 iframe 製作一個易於更新及更安全的前端套件
如何使用 iframe 製作一個易於更新及更安全的前端套件如何使用 iframe 製作一個易於更新及更安全的前端套件
如何使用 iframe 製作一個易於更新及更安全的前端套件Mu Chun Wang
 
pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題
pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題
pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題Mu Chun Wang
 
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構Mu Chun Wang
 
Google Maps 開始收費了該怎麼辦?
Google Maps 開始收費了該怎麼辦?Google Maps 開始收費了該怎麼辦?
Google Maps 開始收費了該怎麼辦?Mu Chun Wang
 
Git 可以做到的事
Git 可以做到的事Git 可以做到的事
Git 可以做到的事Mu Chun Wang
 
那些大家常忽略的 Cache-Control
那些大家常忽略的 Cache-Control那些大家常忽略的 Cache-Control
那些大家常忽略的 Cache-ControlMu Chun Wang
 
如何利用 OpenAPI 及 WebHooks 讓老舊的網路服務也可程式化
如何利用 OpenAPI 及 WebHooks 讓老舊的網路服務也可程式化如何利用 OpenAPI 及 WebHooks 讓老舊的網路服務也可程式化
如何利用 OpenAPI 及 WebHooks 讓老舊的網路服務也可程式化Mu Chun Wang
 
如何與全世界分享你的 Library
如何與全世界分享你的 Library如何與全世界分享你的 Library
如何與全世界分享你的 LibraryMu Chun Wang
 
如何與 Git 優雅地在樹上唱歌
如何與 Git 優雅地在樹上唱歌如何與 Git 優雅地在樹上唱歌
如何與 Git 優雅地在樹上唱歌Mu Chun Wang
 
API Blueprint - API 文件規範的三大領頭之一
API Blueprint - API 文件規範的三大領頭之一API Blueprint - API 文件規範的三大領頭之一
API Blueprint - API 文件規範的三大領頭之一Mu Chun Wang
 
團體共同協作與版本管理 - 01認識共同協作
團體共同協作與版本管理 - 01認識共同協作團體共同協作與版本管理 - 01認識共同協作
團體共同協作與版本管理 - 01認識共同協作Mu Chun Wang
 

Mais de Mu Chun Wang (20)

如何在有限資源下實現十年的後端服務演進
如何在有限資源下實現十年的後端服務演進如何在有限資源下實現十年的後端服務演進
如何在有限資源下實現十年的後端服務演進
 
深入淺出 autocomplete
深入淺出 autocomplete深入淺出 autocomplete
深入淺出 autocomplete
 
你畢業後要任職的軟體業到底都在做些什麼事
你畢業後要任職的軟體業到底都在做些什麼事你畢業後要任職的軟體業到底都在做些什麼事
你畢業後要任職的軟體業到底都在做些什麼事
 
網路服務就是一連串搜尋的集合體
網路服務就是一連串搜尋的集合體網路服務就是一連串搜尋的集合體
網路服務就是一連串搜尋的集合體
 
老司機帶你上手 PostgreSQL 關聯式資料庫系統
老司機帶你上手 PostgreSQL 關聯式資料庫系統老司機帶你上手 PostgreSQL 關聯式資料庫系統
老司機帶你上手 PostgreSQL 關聯式資料庫系統
 
使用 PostgreSQL 及 MongoDB 從零開始建置社群必備的按讚追蹤功能
使用 PostgreSQL 及 MongoDB 從零開始建置社群必備的按讚追蹤功能使用 PostgreSQL 及 MongoDB 從零開始建置社群必備的按讚追蹤功能
使用 PostgreSQL 及 MongoDB 從零開始建置社群必備的按讚追蹤功能
 
Funliday 新創生活甘苦談
Funliday 新創生活甘苦談Funliday 新創生活甘苦談
Funliday 新創生活甘苦談
 
大解密!用 PostgreSQL 提升 350 倍的 Funliday 推薦景點計算速度
大解密!用 PostgreSQL 提升 350 倍的 Funliday 推薦景點計算速度大解密!用 PostgreSQL 提升 350 倍的 Funliday 推薦景點計算速度
大解密!用 PostgreSQL 提升 350 倍的 Funliday 推薦景點計算速度
 
如何使用 iframe 製作一個易於更新及更安全的前端套件
如何使用 iframe 製作一個易於更新及更安全的前端套件如何使用 iframe 製作一個易於更新及更安全的前端套件
如何使用 iframe 製作一個易於更新及更安全的前端套件
 
pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題
pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題
pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題
 
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構
 
Google Maps 開始收費了該怎麼辦?
Google Maps 開始收費了該怎麼辦?Google Maps 開始收費了該怎麼辦?
Google Maps 開始收費了該怎麼辦?
 
Git 可以做到的事
Git 可以做到的事Git 可以做到的事
Git 可以做到的事
 
那些大家常忽略的 Cache-Control
那些大家常忽略的 Cache-Control那些大家常忽略的 Cache-Control
那些大家常忽略的 Cache-Control
 
如何利用 OpenAPI 及 WebHooks 讓老舊的網路服務也可程式化
如何利用 OpenAPI 及 WebHooks 讓老舊的網路服務也可程式化如何利用 OpenAPI 及 WebHooks 讓老舊的網路服務也可程式化
如何利用 OpenAPI 及 WebHooks 讓老舊的網路服務也可程式化
 
如何與全世界分享你的 Library
如何與全世界分享你的 Library如何與全世界分享你的 Library
如何與全世界分享你的 Library
 
如何與 Git 優雅地在樹上唱歌
如何與 Git 優雅地在樹上唱歌如何與 Git 優雅地在樹上唱歌
如何與 Git 優雅地在樹上唱歌
 
API Blueprint - API 文件規範的三大領頭之一
API Blueprint - API 文件規範的三大領頭之一API Blueprint - API 文件規範的三大領頭之一
API Blueprint - API 文件規範的三大領頭之一
 
團體共同協作與版本管理 - 01認識共同協作
團體共同協作與版本管理 - 01認識共同協作團體共同協作與版本管理 - 01認識共同協作
團體共同協作與版本管理 - 01認識共同協作
 
Git 經驗分享
Git 經驗分享Git 經驗分享
Git 經驗分享
 

Último

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Último (20)

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Ruby on rails探索

  • 1. Ruby on Rails 探索 kewang
  • 2. Agenda ● What is Ruby? ● What is Rails? ● Live DEMO ● FAQ ● Q&A 2
  • 3. What is Ruby? 鑽石恆久遠,一顆就破產 3
  • 4. What is Ruby? ● 開放原碼、物件導向的動態直譯式程式語言 ● 簡單哲學、高生產力 ● 精巧、自然的語法 ● 靈感來自 Lisp, Perl, Smalltalk ● 設計的目的是要讓程式設計師 Happy 4
  • 5. Matz 說 ● 一般程式語言的開發目的 ● 可寫出能夠高速運作的程式 ● 可在短期間學會寫程式 ● 寫一次到處都能跑 ● 小朋友也能輕易寫出程式 5
  • 7. Matz Ruby is simple in appearance, but is very complex inside, just like our human body. 7
  • 8. Programming Language Type ● Dynamic Strong Language ● Ruby ● Perl ● Python ● PHP is Dynamic, but is not Strong. ● Java is Strong, but is not Dynamic. 8
  • 12. Features ● Iterator ● Code block (closure) ● ! and ? ● Meta-programming 12
  • 13. Iterator ● 重複做多次類似的事情 ● upto, downto, step, times, collect, map, each_*, *_each, sort...many methods 13
  • 18. ! and ? ● ! means side-effect ● ? means return Boolean 18
  • 19. ! and ? 19
  • 21. RubyGems ● Ruby 的套件管理工具 ● 所有的 Ruby 套件都可以用 gem 安裝 ● Rails ● RMagick ● Heroku ● ...etc. ● http://rubygems.org 21
  • 22. Sinatra ● It's a VERY lightweight web development package ● gem install sinatra ● http://www.sinatrarb.com 22
  • 23. Hello Sinatra ● ruby myapp.rb, and open http://localhost:4567 23
  • 25. Sinatra - XDite 如是說 使用 Sinatra 的目的並不是用來開發那些巨型 的 Web application ,而是搭造那些小型的應 用程式或者 API 介面。這樣做有些什麼好處 呢? 如果你只是想寫一支小型程式,或者開發 API ,並不需要使用 Rails 這麼複雜 ( 或肥 ) 的 Framework 做這些簡單的事。使用 Sinatra 既簡單, Respond 也迅速。 25
  • 26. What is Rails? 火車環島正夯 26
  • 27. What is Rails? ● It's a Web Framework 27
  • 29. What is Rails? ● DHH ● 從 37signals 公司的專案 管理工具 Basecamp 裡面 分離出 Ruby on Rails ● 2005 年獲得年度最佳 Hacker 29
  • 30. What is Rails? ● 正式名稱 Ruby on Rails ● 使用 MVC(Model-View-Control) ● 內建 unit / integration test ● 支援 Ajax, RESTfFul, ORM ● 支援最新技術 HTML5, jQuery, SASS, HAML, Coffee Script 30
  • 31. Design Principles DRY Don't Repeat Yourself 31
  • 32. Design Principles CoC Convention over Configuration 32
  • 33. Rails is so FAST!!! JSP Rails 4 個月,每週約 20 4 個晚上,每晚 5 小 交貨時間 小時 時 程式碼行數 3293 1164 設定檔行數 1161 113 類別數 / 方法數 62/549 55/126 33
  • 35. What is MVC ● Model 包裝了資料與商業邏輯,例如操作資料庫 ● View 表示使用者介面,顯示及編輯表單 ● Controller 將資料送進送出 Model ,處理從外界 來的 HTTP Request ,與 Model 互動後輸出至 View 35
  • 36. DB schema 36
  • 42. What is URL routing? 42
  • 43. a bloated controller class EventController < ApplicationController index /events/index show /events/show/1 new /events/new create /events/create show_comment /events/3/show_comment/6 mark_spamcomment /events/7/mark_spamcomment/5 add_favorite /events/2/add_favorite invite /events/1/invite deny_user /events/1/deny_user/13 allow_user /events/2/allow_user/27 43
  • 44. What is RESTful? before after ActionController /events/create POST /events events#create /events/show/1 GET /events/1 events#show /events/update/1 PUT /events/1 events#update /events/destroy/1 DELETE /events/1 events#destroy 44
  • 45. Let's modify bloated controller class EventController < ApplicationController index GET /events events#index show GET /events/1 events#show new GET /events/new events#new create POST /events events#create show_comment GET /events/3/comments/6 event_comments#show mark_spamcomment PUT /events/7/comments/5/spam event_comments#spam add_favorite POST /events/2/favorite events#favorite invite POST /events/1/invite events#invite deny_user PUT /events/1/users/13/deny event_users#deny allow_user PUT /events/2/users/27/allow event_users#allow 45
  • 46. RESTful routing HTTP Verb Path action GET /photos index GET /photos/new new POST /photos create GET /photos/:id show GET /photos/:id/edit edit PUT /photos/:id update DELETE /photos/:id destroy 46
  • 47. One action, multiple formats 47
  • 48. One action, multiple formats 48
  • 51. Why Ruby? ● Domain-specific language ● Full object-oriented programming ● High usability ● High readability, maintenance 51
  • 52. Why Rails? ● The most successful Web Framework ● Imitation is the greatest compliment ● CakePHP ● Grails ● TurboGears ● catalyst 52
  • 53. Websites 53
  • 54. Performance Comparison PHP 5.2.3 Python 2.5.1 Lines of Code Time per iteration Language Ruby 1.9.0 (microseconds) C++ 4.2.3 Java 1.6 0 100 200 300 400 500 600 700 54 愈小愈好
  • 55. Performance is slow? ● 如果一個框架可以讓你僅變快 20% ,或許你應該 繼續使用比較保險的語言,像是 Java 。但是如果 你可以變快 300% 甚至更高,那麼其他的差異都 變的不重要了 from Beyond Java 55