• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan
 

Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan

on

  • 822 views

 

Statistics

Views

Total Views
822
Views on SlideShare
822
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan  Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan Presentation Transcript

    • Ruby on Rails Pengenalan kepada “permata” dalam pengaturcaraan
    • السلام عليكم Salam sejahtera
    • Sabah Open Source Group http://sabahopensource.org http://facebook.com/sabahopensource join us :-)
    • Ruby on Rails
    • Ruby on Rails
    • www.ruby-lang.org
    • Apa itu Ruby?
        Sebuah lagi Programming Language!
    • Ruby adalah .....
        Sebuah lagi Programming Language sumber terbuka dan dinamik dengan fokus kepada kesenangan dan produktiviti .
    • Ruby adalah .....
        Ianya mempunyai sintaks yang semulajadi untuk dibaca dan mudah ditulis .
    • Mengapa Ruby?
      • Mudah dan indah
      • Sumber terbuka
      • Ruby on Rails (Web Framework)
      • Ruby Boleh!
        • Manipulasi teks
        • Pentadbiran sistem
        • Aplikasi sains
        • Dan banyak lagi .....
    • Siapa gunakannya?
    • Sejarah Ruby
      • Yukihiro “Matz” Matsumoto
        • Jepun
        • 24 Februari 1993
    • Sejarah Ruby
        Perl Python Java Ruby PHP 87 89 91 93 95
    • Falsafah
        “ 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”
    • Falsafah
        “ Ruby is simple in appearance, but is very complex inside, just like our human body”
    • Prinsip
        Software Development Tools direka untuk komputer, bukan untuk manusia.
    • Prinsip
        Komputer kerja untuk manusia, bukan DAN jangan sebaliknya!
    • Prinsip
        Language dan Library untuk manusia dahulu!
    • Teman
        Ruby – Teman baik sang pengaturcara
    • Kod
        ucapan = “Saya suka Ruby” puts ucapan => “Saya suka Ruby”
    • Kod
        ucapan = “Saya suka Ruby” # tiada type declaration puts ucapan # tiada “main()” method # tiada keyword tambahan (“var”) => “Saya suka Ruby”
    • Kod
        5.times{ print “1 Malaysia ” } => “1 Malaysia” => “1 Malaysia” => “1 Malaysia” => “1 Malaysia” => “1 Malaysia”
    • Data types
        “ 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
    • Data types
        “ 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”
    • Flow
        car = “toyota” if car == “toyota” puts “Toyota VIOS” else puts “Unknown car” end
    • Flow (ternary)
        car = “toyota” car == “toyota” ? puts( “Toyota VIOS” ) : puts( “Unknown model” )
    • Flow
        car = “toyota” case car when “toyota” puts “Toyota VIOS” when “proton” puts “Proton Saga” end
    • Manipulasi string
        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”
    • OOP
        name = “Edham Arief” name.upcase
    • OOP
        class User
          attr_accessor :name, :email def hello; puts( “Hello world” ); end
        end user1 = User.new “J. Bond” , “ [email_address] ” user2 = User.new “Obama” , “ [email_address] ” user1.hello => “Hello world” user2.hello => “Hello world”
    • Advance
        ciri_ciri_ruby_advance= {
          :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” }
    • Ruby on Rails
    • www.rubyonrails.org
    • Apa itu RoR?
        Sebuah lagi Web Application Framework!
    • Ruby on Rails adalah ...
        ... web framework sumber terbuka yang ditujukan untuk kegembiraan pengaturcara dan produktiviti. Ianya membuatkan anda menulis kod yang indah dengan mengetengahkan “Convention over Configuration”
    • Mengapa RoR?
        Convention over Configuration MVC Kurang kod Don't Repeat Yourself (DRY) Ekosistem
    • Mengapa RoR?
        Bina Blog dalam 15 minit
          http://rubyonrails.org/screencasts
        Screencasts Rails percuma
          http://railscasts.com
    • Siapa gunakannya?
    • Sejarah RoR?
        37 Signals
          http://37signals.com
        Basecamp ~ 2004
          http://basecamphq.com/
        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
    • Falsafah
        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.”
    • Falsafah
        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.”
    • Binaan asas
    • Kurang code
        Scaffold $./script/generate scaffold user name:string email:string (demo)
    • Representational State Transfer
        Selalunya aplikasi web adalah berasaskan object
        • Posting dalam blog
          • Entry database (title, content dan date)
        • User dalam sistem maklumat
          • Entry database (name, mykad dan jabatan)
        REST – create read update delete HTTP – post get put delete
    • Representational State Transfer
        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)
    • Representational State Transfer
        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)
    • Representational State Transfer
        Didatangkan percuma dengan Ruby on Rails
    • Don't Repeat Yourself
        Kod binaan asas (boiler plate) berkurangan! Don't reinvent the wheel!
    • Ekosistem
        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
    • DEMO
        DEMO BINAAN SISTEM RINGKAS harap sempat siap :-) Sistem rekodJabatan dan pekerja setiap jabatan tersebut!
      • departments(code, phone_no)
      • employee(name, email, department_id)
    • Penghargaan
        Terima kasih :-)
    • Sumber dan rujukan
      • Slide http://www.slideshare.net/madrobby/ruby-on-rails-introduction
      • Gambar MVC ( http://wiki.nectec.or.th/gitiwiki/pub/Knowledge/ModelViewController/mvc-rails.png )
      • Gambar DHH (google)
      • Gambar Matz (google)
      • Gambar scaffold ( http://web.princeton.edu/sites/ehs/pmguide/scaffold.gif )
      • Gambar basikal (http://dev102.com/Dev102/wp-content/uploads/2008/11/reinventthe-wheel.png)
      • Web rasmi RoR - http://rubyonrails.org
      • Web rasmi Ruby - http://ruby-lang.org
      • Wikipedia
      • Disertasi asal REST ( http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm )
      • Template Open Office Impress ini - ( http://technology.chtsai.org/impress/ )