Transcript
Page 1: Five Minutes Introduction For Rails
Page 2: Five Minutes Introduction For Rails

Presents

Page 3: Five Minutes Introduction For Rails

JINNISHIKAWA

SHINTAROKAKUTANI

Special Thanks

Page 4: Five Minutes Introduction For Rails

ESMLLWG

EIJIIENAGA

Special Thanks

AND

Page 5: Five Minutes Introduction For Rails

人はあらゆるプロセスよりも重要である。優れた人々に優れたプロセスを与えれば、プロセスを持たない優れた人々よりも常に効率が上がる。

ー Grady Booch

Page 6: Five Minutes Introduction For Rails

2005年12月13日

On December 13, 2005 the David Heinemeier Hanson major releasedon excellent framework for the all of its programmers.Its purpose was to get back the lost Quality of Engineering Lifeand to insure that the all of men who comprehensivewere the nice programmers in the world.

They succeeded.

Today, the Programmer calls it Web Application Framework.The programmers call it:

Page 7: Five Minutes Introduction For Rails

DHHはすべての

プログラマーのために

On December 13, 2005 the David Heinemeier Hanson major releasedon excellent framework for the all of its programmers.Its purpose was to get back the lost Quality of Engineering Lifeand to insure that the all of men who comprehensivewere the nice programmers in the world.

They succeeded.

Today, the Programmer calls it Web Application Framework.The programmers call it:

Page 8: Five Minutes Introduction For Rails

WebアプリケーションF/Wを

メジャーリリースした

On December 13, 2005 the David Heinemeier Hanson major releasedon excellent framework for the all of its programmers.Its purpose was to get back the lost Quality of Engineering Lifeand to insure that the all of men who comprehensivewere the nice programmers in the world.

They succeeded.

Today, the Programmer calls it Web Application Framework.The programmers call it:

Page 9: Five Minutes Introduction For Rails

目的は失われつつあるエンジニア人生の質

On December 13, 2005 the David Heinemeier Hanson major releasedon excellent framework for the all of its programmers.Its purpose was to get back the lost Quality of Engineering Lifeand to insure that the all of men who comprehensivewere the nice programmers in the world.

They succeeded.

Today, the Programmer calls it Web Application Framework.The programmers call it:

Page 10: Five Minutes Introduction For Rails

世界最高のWebアプリケーションF/Wの

呼び名は

On December 13, 2005 the David Heinemeier Hanson major releasedon excellent framework for the all of its programmers.Its purpose was to get back the lost Quality of Engineering Lifeand to insure that the all of men who comprehensivewere the nice programmers in the world.

They succeeded.

Today, the Programmer calls it Web Application Framework.The programmers call it:

Page 11: Five Minutes Introduction For Rails
Page 12: Five Minutes Introduction For Rails

分間の 入門

Get back the lost Quality of Engineering Life with

Page 13: Five Minutes Introduction For Rails

Part1: RailsPart1: Railsの思想の思想Part2: RailsPart2: Railsの構成の構成Part3: RailsPart3: RailsととRubyRuby

Page 14: Five Minutes Introduction For Rails

の思想

1.1.DRYDRY2.2.CoCCoC

Page 15: Five Minutes Introduction For Rails

DonDon ’’ ttRepeatRepeat

YourselfYourself

繰り返しを避けること

Page 16: Five Minutes Introduction For Rails

ConventionConventionoverover

ConfigurationConfiguration

設定よりも規約

Page 17: Five Minutes Introduction For Rails

まとめ

あとで

あとで

あとで書くあとで書く

あとで書く

Page 18: Five Minutes Introduction For Rails

の構成1.1.ARAR2.2.APAP3.3.RailsRails

Page 19: Five Minutes Introduction For Rails

ORMのパッケージ

Page 20: Five Minutes Introduction For Rails

より

PoEAAで紹介されているORMパターンのひとつ

http://http://capsctrl.que.jp/kdmsnr/wiki/PofEAA/?ActiveRecordcapsctrl.que.jp/kdmsnr/wiki/PofEAA/?ActiveRecord

データベースのテーブルデータベースのテーブルやビューの列をラップし、やビューの列をラップし、データベースアクセスをカデータベースアクセスをカプセル化し、ドメインロジップセル化し、ドメインロジックを追加するオブジェクトクを追加するオブジェクト

Page 21: Five Minutes Introduction For Rails

class Person < ActiveRecord::Baseend

app/models/app/models/person.rbperson.rb

ActiveRecord::Baseを継承

Page 22: Five Minutes Introduction For Rails

データベース管理

MigrationによるDB管理が可能

class CreatePeople < ActiveRecord::Migrationdef self.up

create_table :people do |table|table.column :first_name, :string, :limit => 32table.column :last_name, :string, :limit => 32table.column :number_of_dependents, :integer

endenddef self.down

drop_table :peopleend

end

db/migrate/001_create_people.rbdb/migrate/001_create_people.rb

Page 23: Five Minutes Introduction For Rails

ドメイン特化言語としてのRuby

RubyRubyだけ知っていればだけ知っていれば

よいか?よいか?

の威力

Page 24: Five Minutes Introduction For Rails

SQLの知識は重要、超重要

Page 25: Five Minutes Introduction For Rails

ActionControllerとActionViewを含むパッケージ

Page 26: Five Minutes Introduction For Rails

class PeopleController < ActionController::Basedef show@person = Person.find(params[:id])

endend

app/controllers/app/controllers/people_controller.rbpeople_controller.rb

ActionController::Baseを継承

Page 27: Five Minutes Introduction For Rails

<% for column in Person.content_columns %><p><b><%= column.human_name %>:</b><%=h @person.send(column.name) %>

</p><% end %>

app/views/people/app/views/people/show.rhtmlshow.rhtml

コントローラとインスタンス変数を共有する

Page 28: Five Minutes Introduction For Rails

<html><head><title><%= controller.action_name %></title>

</head><body><%= @content_for_layout %>

</body></html>

app/views/layouts/app/views/layouts/people.rhtmlpeople.rhtml

レイアウトを使って共通するビューをまとめる

Page 29: Five Minutes Introduction For Rails

レイヤーをつなげる線路

Page 30: Five Minutes Introduction For Rails

まとめ

ToolToolMattersMatters

職人は道具を選ぶ

道具重要

道具重要

Page 31: Five Minutes Introduction For Rails

と1.1.DSLDSL2.2.AgileAgile3.3.FunFun

Page 32: Five Minutes Introduction For Rails

なぜなぜDSLDSLが大事か?が大事か?

Page 33: Five Minutes Introduction For Rails

Human ReadableHuman Readable

コードは人間にとって読み易くあるべき

の効用

Page 34: Five Minutes Introduction For Rails

1.1.括弧を省略できる括弧を省略できる2.2.シンボルがオブジェクトシンボルがオブジェクト3.3.ブロックがあるブロックがある((名前空間の重複を防げる名前空間の重複を防げる))

http://blog.nikkeibp.co.jp/itpro/java/archives/2006/02/rubydsl.hhttp://blog.nikkeibp.co.jp/itpro/java/archives/2006/02/rubydsl.htmltml

RubyがDSLに向く3つの理由

宣言的な記述が可能

Page 35: Five Minutes Introduction For Rails

Is Is RubyRuby Agile?Agile?

オブジェクト倶楽部2005年クリスマスイベントにて

http://www.objectclub.jp/event/2005christmas/schedule#2http://www.objectclub.jp/event/2005christmas/schedule#2--22

Page 36: Five Minutes Introduction For Rails

まつもとさんの答え

Rubyはアジャイルである

http://www.rubyist.net/~matz/slides/oc2005/mgp00005.htmlhttp://www.rubyist.net/~matz/slides/oc2005/mgp00005.html

Page 37: Five Minutes Introduction For Rails

あとで書くあとで書く

あとで書く

Page 38: Five Minutes Introduction For Rails

まとめ

誇りと希望を持った仕事が誇りと希望を持った仕事がQoELQoELにつながるにつながる

Page 39: Five Minutes Introduction For Rails

結論コンパイルコンパイル / / ビルドのビルドの

終わりを終わりを待っているほど待っているほど

人生は長くはない人生は長くはないアジャイルな人の道具にはRubyが馴染むと思うのです

Page 40: Five Minutes Introduction For Rails

EnjoyEnjoyEngineering LifeEngineering Life

Page 41: Five Minutes Introduction For Rails

Top Related