Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan

850 views

Published on

Published in: Spiritual
  • Be the first to comment

  • Be the first to like this

Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan

  1. 1. Ruby on Rails Pengenalan kepada “permata” dalam pengaturcaraan
  2. 2. السلام عليكم Salam sejahtera
  3. 3. Sabah Open Source Group http://sabahopensource.org http://facebook.com/sabahopensource join us :-)
  4. 4. Ruby on Rails
  5. 5. Ruby on Rails
  6. 6. www.ruby-lang.org
  7. 7. Apa itu Ruby? <ul>Sebuah lagi Programming Language! </ul>
  8. 8. Ruby adalah ..... <ul>Sebuah lagi Programming Language sumber terbuka dan dinamik dengan fokus kepada kesenangan dan produktiviti . </ul>
  9. 9. Ruby adalah ..... <ul>Ianya mempunyai sintaks yang semulajadi untuk dibaca dan mudah ditulis . </ul>
  10. 10. Mengapa Ruby? <ul><li>Mudah dan indah
  11. 11. Sumber terbuka
  12. 12. Ruby on Rails (Web Framework)
  13. 13. Ruby Boleh! </li><ul><li>Manipulasi teks
  14. 14. Pentadbiran sistem
  15. 15. Aplikasi sains
  16. 16. Dan banyak lagi ..... </li></ul></ul>
  17. 17. Siapa gunakannya?
  18. 18. Sejarah Ruby <ul><li>Yukihiro “Matz” Matsumoto </li><ul><li>Jepun
  19. 19. 24 Februari 1993 </li></ul></ul>
  20. 20. Sejarah Ruby <ul>Perl Python Java Ruby PHP 87 89 91 93 95 </ul>
  21. 21. Falsafah <ul>“ I wanted a scripting language that was more powerful than Perl, and more object-oriented than Python. That's why I decided to design my own language” </ul>
  22. 22. Falsafah <ul>“ Ruby is simple in appearance, but is very complex inside, just like our human body” </ul>
  23. 23. Prinsip <ul>Software Development Tools direka untuk komputer, bukan untuk manusia. </ul>
  24. 24. Prinsip <ul>Komputer kerja untuk manusia, bukan DAN jangan sebaliknya! </ul>
  25. 25. Prinsip <ul>Language dan Library untuk manusia dahulu! </ul>
  26. 26. Teman <ul>Ruby – Teman baik sang pengaturcara </ul>
  27. 27. Kod <ul>ucapan = “Saya suka Ruby” puts ucapan => “Saya suka Ruby” </ul>
  28. 28. Kod <ul>ucapan = “Saya suka Ruby” # tiada type declaration puts ucapan # tiada “main()” method # tiada keyword tambahan (“var”) => “Saya suka Ruby” </ul>
  29. 29. Kod <ul>5.times{ print “1 Malaysia ” } => “1 Malaysia” => “1 Malaysia” => “1 Malaysia” => “1 Malaysia” => “1 Malaysia” </ul>
  30. 30. Data types <ul>“ Ini adalah string” # string 'Ini juga adalah string' # string 1 # fixnum (tiada tempat perpuluhan) 1.2 # float (ada tempat perpuluhan) cars = [“proton”, “perodua”, “naza”] # float kamus = { :big => “besar”, :small => “kecil” } # hash </ul>
  31. 31. Data types <ul>“ Ini adalah string” .class => “String” 'Ini juga adalah string' .class => “String” 1 .class => “Fixnum” 1.2 .class => “Float” cars = [“proton”, “perodua”, “naza”] cars .class => “Array” kamus = { :big => “besar”, :small => “kecil” } kamus .class => “Hash” </ul>
  32. 32. Flow <ul>car = “toyota” if car == “toyota” puts “Toyota VIOS” else puts “Unknown car” end </ul>
  33. 33. Flow (ternary) <ul>car = “toyota” car == “toyota” ? puts( “Toyota VIOS” ) : puts( “Unknown model” ) </ul>
  34. 34. Flow <ul>car = “toyota” case car when “toyota” puts “Toyota VIOS” when “proton” puts “Proton Saga” end </ul>
  35. 35. Manipulasi string <ul>name = “Edham Arief” name.upcase => “EDHAM ARIEF” name.downcase => “edham arief” name.reverse => “feirA mahdE” name.downcase.reverse => “feira mahde” name.length => 11 name.sub(“Edham”, “Encik”) => “Encik Arief” </ul>
  36. 36. OOP <ul>name = “Edham Arief” name.upcase </ul>
  37. 37. OOP <ul>class User <ul>attr_accessor :name, :email def hello; puts( “Hello world” ); end </ul>end user1 = User.new “J. Bond” , “ [email_address] ” user2 = User.new “Obama” , “ [email_address] ” user1.hello => “Hello world” user2.hello => “Hello world” </ul>
  38. 38. Advance <ul>ciri_ciri_ruby_advance= { <ul>:metaprogramming => “kod yang menulis kod lain” , :full_oop => “everything is an object” , :reflection => “setiap object kenal diri sendiri” , :duck_typing => “if it sounds, walks and talks like a duck ...” , :dsl => “domain specific languages” , :libraries => “beribu-ribu library” } </ul></ul>
  39. 39. Ruby on Rails
  40. 40. www.rubyonrails.org
  41. 41. Apa itu RoR? <ul>Sebuah lagi Web Application Framework! </ul>
  42. 42. Ruby on Rails adalah ... <ul>... web framework sumber terbuka yang ditujukan untuk kegembiraan pengaturcara dan produktiviti. Ianya membuatkan anda menulis kod yang indah dengan mengetengahkan “Convention over Configuration” </ul>
  43. 43. Mengapa RoR? <ul>Convention over Configuration MVC Kurang kod Don't Repeat Yourself (DRY) Ekosistem </ul>
  44. 44. Mengapa RoR? <ul>Bina Blog dalam 15 minit <ul>http://rubyonrails.org/screencasts </ul>Screencasts Rails percuma <ul>http://railscasts.com </ul></ul>
  45. 45. Siapa gunakannya?
  46. 46. Sejarah RoR? <ul>37 Signals <ul>http://37signals.com </ul>Basecamp ~ 2004 <ul>http://basecamphq.com/ </ul>Versions: 1.0 1.2 2.0 2.1 2.2 2.3 3.0 Dec 2005 Jan 2007 Dec 2007 Jun 2008 Nov 2008 Mar 2009 2010 </ul>
  47. 47. Falsafah <ul>David Heinemeier Hansson (DHH) “ What separates programmers who are 10x more effective than the norm is not that they write 10x as many lines of code. It’s that they use their creativity to solve the problem with 1/10th of the effort.” </ul>
  48. 48. Falsafah <ul>David Heinemeier Hansson (DHH) “ In the beginning, there was no Rails, there was only Basecamp. After working on Basecamp for a while, though, I eyed the option of giving all the generic pieces a life of their own. But even then, I continued to work on Basecamp first. Which meant that all the functionality of Rails came as extractions of a real application, not of a “what somebody might need some day” fantasy, so prevalent in framework design.” </ul>
  49. 49. Binaan asas
  50. 50. Kurang code <ul>Scaffold $./script/generate scaffold user name:string email:string (demo) </ul>
  51. 51. Representational State Transfer <ul>Selalunya aplikasi web adalah berasaskan object <ul><li>Posting dalam blog </li><ul><li>Entry database (title, content dan date) </li></ul><li>User dalam sistem maklumat </li><ul><li>Entry database (name, mykad dan jabatan) </li></ul></ul>REST – create read update delete HTTP – post get put delete </ul>
  52. 52. Representational State Transfer <ul>URL konsisten dan mudah diteka GET http://site.com/posts papar semua GET http://site.com/posts/1 papar post (id=1) GET http://site.com/posts/new papar form untuk rekod baru GET http://site.com/posts/1/edit papar form edit post (id=1) POST http://site.com/posts bina rekod baru PUT http://site.com/posts/1 update post (id=1) DELETE http://site.com/posts/1 padam post (id=1) </ul>
  53. 53. Representational State Transfer <ul>URL konsisten dan mudah diteka GET http://site.com/users papar semua GET http://site.com/users/1 papar user (id=1) GET http://site.com/users/new papar form untuk rekod baru GET http://site.com/users/1/edit papar form edit user (id=1) POST http://site.com/users/ bina rekod baru PUT http://site.com/users/1 update user (id=1) DELETE http://site.com/users/1 padam user (id=1) </ul>
  54. 54. Representational State Transfer <ul>Didatangkan percuma dengan Ruby on Rails </ul>
  55. 55. Don't Repeat Yourself <ul>Kod binaan asas (boiler plate) berkurangan! Don't reinvent the wheel! </ul>
  56. 56. Ekosistem <ul>Editor – Textmate (Mac OS), Eclipse, Netbeans, Emacs, vim, notepad OS – Linux, Mac OS, Windows Community – malaysia.rb, wiki, irc, mailing lists Repositori kod - http://github.com </ul>
  57. 57. DEMO <ul>DEMO BINAAN SISTEM RINGKAS harap sempat siap :-) Sistem rekodJabatan dan pekerja setiap jabatan tersebut! <li>departments(code, phone_no)
  58. 58. employee(name, email, department_id) </li></ul>
  59. 59. Penghargaan <ul>Terima kasih :-) </ul>
  60. 60. Sumber dan rujukan <ul><li>Slide http://www.slideshare.net/madrobby/ruby-on-rails-introduction
  61. 61. Gambar MVC ( http://wiki.nectec.or.th/gitiwiki/pub/Knowledge/ModelViewController/mvc-rails.png )
  62. 62. Gambar DHH (google)
  63. 63. Gambar Matz (google)
  64. 64. Gambar scaffold ( http://web.princeton.edu/sites/ehs/pmguide/scaffold.gif )
  65. 65. Gambar basikal (http://dev102.com/Dev102/wp-content/uploads/2008/11/reinventthe-wheel.png)
  66. 66. Web rasmi RoR - http://rubyonrails.org
  67. 67. Web rasmi Ruby - http://ruby-lang.org
  68. 68. Wikipedia
  69. 69. Disertasi asal REST ( http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm )
  70. 70. Template Open Office Impress ini - ( http://technology.chtsai.org/impress/ ) </li></ul>

×