SlideShare uma empresa Scribd logo
1 de 36
Baixar para ler offline
Happy Coding with

 Ruby on Rails
      Maahai L.Ochirkhuyag




2009-6-6 @MAJ Meeting, Tokyo
Ochirkhuyag.is_who?

       ochko.blogspot.com
       maaxai.blogspot.com

         2000~ programming
           2005~ USI Inc.
2008~2010 Waseda Univ. Master's course

         2007~ Ruby & RoR
Ruby




“more powerful than Perl, and more OO
           than Python”

“interpreted, object-oriented, portable,
      untyped, garbage collected”
Yukihiro ‘Matz’ Matsumoto,
      creator of Ruby:
           “Often people, especially
           computer engineers, focus on the
           machines. They think, quot;By doing
           this, the machine will run faster.
           By doing this, the machine will
           run more effectively. By doing
           this, ... But in fact we need to
           focus on humans, on how
           humans care about doing
           programming or operating the
           application of the machines. We
           are the masters. They are the
           slaves.”
Everything is Object
>> 2009.class              # → Fixnum


>> :lets_start.class       # → Symbol


>> quot;ruby is suckingquot;.capitalize
# → quot;Ruby is suckingquot;


>> 3.times {puts quot;Сайн уу?quot;}
Сайн уу?
Сайн уу?
Сайн уу?
Ruby array is Powerful
>> a = [ 1, 2, 3, 'four', 'V', nil, 2 ]
=> [1, 2, 3, quot;fourquot;, quot;Vquot;, nil, 2]
>> a.compact.uniq
=> [1, 2, 3, quot;fourquot;, quot;Vquot;]
>> [1, 2, 3, 4, 5, 6].select { |e| e % 2 == 0 }
=> [2, 4, 6]
>> [1, 2, 3, 4].inject(0) { |res, el| res + el }
=> 10
Ruby classes are Open
# Numeric is ruby's built-in class
# We can add a method to it


class Numeric
  def plus(x)
      self.+(x)
  end
end


5.plus 6          # → 11
Block is Expressive
search_engines =
  %w[Google Yahoo MSN].map do |engine|
    quot;http://www.quot; + engine.downcase + quot;.comquot;
  end


# → [ quot;http://www.google.comquot;,
        quot;http://www.yahoo.comquot;,
        quot;http://www.msn.comquot; ]
Built-in Regular expression
//.class
# → Regexp


a = quot;the quick brown foxquot;


a =~ /q[uia]*ck/
# → 4


a.gsub(/[aeiou]/, '*')
# → quot;th* q**ck br*wn f*xquot;
Mixin
class MyArray
  include Enumerable
  # implement each
end


m = MyArray.new()
m << 1 << 2 << 3
m.find{|e| e % 2 == 0}
# → 2
try ruby! (in your browser)

http://tryruby.hobix.com/
David ‘dhh’ Heinemeier Hansson,
    creator of Ruby on Rails

                ●
                    Convention over
                    Configuration
                ●
                    DRY
                ●
                    High Productivity
Websites on Rails
Ruby on Rails vs...
Java     Python    PHP       Ruby




etc.      etc.     etc.      etc.
MVC Architecture
Convention over
 Configuration


     CoC
http://app/weblog
/app/views/weblog
http://app/weblog/show/9
/app/views/weblog/show.rhtml
Don't Repeat Yourself(DRY)
Productivity ← Motivation ←
Happiness ← Beautiful Code
Happy Coding Demo
Q&A

            ?
if you.want? contact_me_by {
       :twitter => ochko,
       :github => ochko }
References
●   http://marklunds.com/rails101
●   http://www.slideshare.net/Joopp/ruby-on-rails-presentation-presentation
●   http://media.rubyonrails.org/presentations/programminghappiness.pdf
●   http://media.rubyonrails.org/video/rails_blog_2.mov

Mais conteúdo relacionado

Semelhante a Happy Coding with Ruby on Rails

When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Railsdosire
 
IronRuby - A brave new world for .Net (NDC2010)
IronRuby - A brave new world for .Net (NDC2010)IronRuby - A brave new world for .Net (NDC2010)
IronRuby - A brave new world for .Net (NDC2010)Ben Hall
 
Arulalan Ruby An Intro
Arulalan  Ruby An IntroArulalan  Ruby An Intro
Arulalan Ruby An IntroArulalan T
 
Intro To Django
Intro To DjangoIntro To Django
Intro To DjangoUdi Bauman
 
Automated Testing with Ruby
Automated Testing with RubyAutomated Testing with Ruby
Automated Testing with RubyKeith Pitty
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Librariesjeresig
 
Sinatraonpassenger 090419090519 Phpapp01
Sinatraonpassenger 090419090519 Phpapp01Sinatraonpassenger 090419090519 Phpapp01
Sinatraonpassenger 090419090519 Phpapp01guestcaceba
 
Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!cloudbring
 
DiUS Computing Lca Rails Final
DiUS  Computing Lca Rails FinalDiUS  Computing Lca Rails Final
DiUS Computing Lca Rails FinalRobert Postill
 
Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)True-Vision
 
yet another rails
yet another railsyet another rails
yet another railsashok kumar
 
Scaling Rails Presentation
Scaling Rails PresentationScaling Rails Presentation
Scaling Rails Presentationeraz
 
Padrino is agnostic
Padrino is agnosticPadrino is agnostic
Padrino is agnosticTakeshi Yabe
 
Turbogears Presentation
Turbogears PresentationTurbogears Presentation
Turbogears Presentationdidip
 

Semelhante a Happy Coding with Ruby on Rails (20)

When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
IronRuby - A brave new world for .Net (NDC2010)
IronRuby - A brave new world for .Net (NDC2010)IronRuby - A brave new world for .Net (NDC2010)
IronRuby - A brave new world for .Net (NDC2010)
 
Arulalan Ruby An Intro
Arulalan  Ruby An IntroArulalan  Ruby An Intro
Arulalan Ruby An Intro
 
Intro To Django
Intro To DjangoIntro To Django
Intro To Django
 
Ignite
IgniteIgnite
Ignite
 
Automated Testing with Ruby
Automated Testing with RubyAutomated Testing with Ruby
Automated Testing with Ruby
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Libraries
 
Sinatraonpassenger 090419090519 Phpapp01
Sinatraonpassenger 090419090519 Phpapp01Sinatraonpassenger 090419090519 Phpapp01
Sinatraonpassenger 090419090519 Phpapp01
 
SearchMonkey
SearchMonkeySearchMonkey
SearchMonkey
 
Sinatra
SinatraSinatra
Sinatra
 
Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!
 
JSON Viewer XPATH Workbook
JSON Viewer XPATH WorkbookJSON Viewer XPATH Workbook
JSON Viewer XPATH Workbook
 
DiUS Computing Lca Rails Final
DiUS  Computing Lca Rails FinalDiUS  Computing Lca Rails Final
DiUS Computing Lca Rails Final
 
Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)
 
yet another rails
yet another railsyet another rails
yet another rails
 
Scaling Rails Presentation
Scaling Rails PresentationScaling Rails Presentation
Scaling Rails Presentation
 
Scaling Scribd
Scaling ScribdScaling Scribd
Scaling Scribd
 
Padrino is agnostic
Padrino is agnosticPadrino is agnostic
Padrino is agnostic
 
20090422 Www
20090422 Www20090422 Www
20090422 Www
 
Turbogears Presentation
Turbogears PresentationTurbogears Presentation
Turbogears Presentation
 

Último

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 

Último (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 

Happy Coding with Ruby on Rails

  • 1. Happy Coding with Ruby on Rails Maahai L.Ochirkhuyag 2009-6-6 @MAJ Meeting, Tokyo
  • 2. Ochirkhuyag.is_who? ochko.blogspot.com maaxai.blogspot.com 2000~ programming 2005~ USI Inc. 2008~2010 Waseda Univ. Master's course 2007~ Ruby & RoR
  • 3. Ruby “more powerful than Perl, and more OO than Python” “interpreted, object-oriented, portable, untyped, garbage collected”
  • 4. Yukihiro ‘Matz’ Matsumoto, creator of Ruby: “Often people, especially computer engineers, focus on the machines. They think, quot;By doing this, the machine will run faster. By doing this, the machine will run more effectively. By doing this, ... But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves.”
  • 5. Everything is Object >> 2009.class # → Fixnum >> :lets_start.class # → Symbol >> quot;ruby is suckingquot;.capitalize # → quot;Ruby is suckingquot; >> 3.times {puts quot;Сайн уу?quot;} Сайн уу? Сайн уу? Сайн уу?
  • 6. Ruby array is Powerful >> a = [ 1, 2, 3, 'four', 'V', nil, 2 ] => [1, 2, 3, quot;fourquot;, quot;Vquot;, nil, 2] >> a.compact.uniq => [1, 2, 3, quot;fourquot;, quot;Vquot;] >> [1, 2, 3, 4, 5, 6].select { |e| e % 2 == 0 } => [2, 4, 6] >> [1, 2, 3, 4].inject(0) { |res, el| res + el } => 10
  • 7. Ruby classes are Open # Numeric is ruby's built-in class # We can add a method to it class Numeric def plus(x) self.+(x) end end 5.plus 6 # → 11
  • 8. Block is Expressive search_engines = %w[Google Yahoo MSN].map do |engine| quot;http://www.quot; + engine.downcase + quot;.comquot; end # → [ quot;http://www.google.comquot;, quot;http://www.yahoo.comquot;, quot;http://www.msn.comquot; ]
  • 9. Built-in Regular expression //.class # → Regexp a = quot;the quick brown foxquot; a =~ /q[uia]*ck/ # → 4 a.gsub(/[aeiou]/, '*') # → quot;th* q**ck br*wn f*xquot;
  • 10. Mixin class MyArray include Enumerable # implement each end m = MyArray.new() m << 1 << 2 << 3 m.find{|e| e % 2 == 0} # → 2
  • 11. try ruby! (in your browser) http://tryruby.hobix.com/
  • 12.
  • 13. David ‘dhh’ Heinemeier Hansson, creator of Ruby on Rails ● Convention over Configuration ● DRY ● High Productivity
  • 15. Ruby on Rails vs... Java Python PHP Ruby etc. etc. etc. etc.
  • 17.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 33. Productivity ← Motivation ← Happiness ← Beautiful Code
  • 35. Q&A ? if you.want? contact_me_by { :twitter => ochko, :github => ochko }
  • 36. References ● http://marklunds.com/rails101 ● http://www.slideshare.net/Joopp/ruby-on-rails-presentation-presentation ● http://media.rubyonrails.org/presentations/programminghappiness.pdf ● http://media.rubyonrails.org/video/rails_blog_2.mov