software development and rubygems

78
受託開発 (株) 永和システムマネジメント アジャイル事業部 Ruby x Agile グループ 伊藤 浩一 (@koic) Enjoy Programming RubyGems gem install active_pstore エムオーテックス新大阪ビル エムオーテックスホール 2015.07.11 (Sat ) 関西Ruby会議 06

Upload: koichi-ito

Post on 07-Aug-2015

505 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Software Development and RubyGems

受託開発と(株) 永和システムマネジメント

アジャイル事業部 Ruby x Agile グループ

伊藤 浩一 (@koic)

Enjoy Programming

RubyGemsgem install active_pstore

エムオーテックス新大阪ビル エムオーテックスホール2015.07.11 (Sat)関西Ruby会議06

Page 2: Software Development and RubyGems

Computer programmer, guitarist.Leader of an Agile software development team

at Eiwa System Management, Inc.Lives in Shinjuku.

@koic photo token by @NaCl

Page 3: Software Development and RubyGems
Page 4: Software Development and RubyGems
Page 5: Software Development and RubyGems
Page 6: Software Development and RubyGems
Page 7: Software Development and RubyGems

XPE2ndと

上司がついて

きます

https://pbs.twimg.com/media/CIZYfj6W8AAqyAU.jpg

Page 8: Software Development and RubyGems

今日の話

Page 9: Software Development and RubyGems

“GUIが使えない場合はシェルを使う。

受託開発で色々なシステムを作った知見からライブラリを作れそう

Page 10: Software Development and RubyGems

実践投入された実装とされていない構想

Page 11: Software Development and RubyGems

構想の副産物

Page 12: Software Development and RubyGems
Page 13: Software Development and RubyGems

背景

Page 14: Software Development and RubyGems

いち場面

受託開発の

Page 15: Software Development and RubyGems

https://ja.wikipedia.org/wiki/正岡子規#/media/File:Masaoka_Shiki.jpg

誰のためのコード

Page 16: Software Development and RubyGems

日時予約して1回だけ実行したい

(あるある)

Page 17: Software Development and RubyGems

運用の自動化

Page 18: Software Development and RubyGems

at コマンド

Page 19: Software Development and RubyGems
Page 20: Software Development and RubyGems

permission denied

Page 21: Software Development and RubyGems

受託開発にはコントロールできることとできないことがある

Page 22: Software Development and RubyGems

立ちはだかる壁

Page 23: Software Development and RubyGems

オンプレhttps://ja.wikipedia.org/wiki/%E3%82%B3%E3%83%B3%E3%83%94%E3%83%A5%E3%83%BC%E3%82%BF#/media/File:Dell_PowerEdge_Servers.jpg

Page 24: Software Development and RubyGems

申請書

Page 25: Software Development and RubyGems

営業日

Page 26: Software Development and RubyGems

さまざまな制約

Page 27: Software Development and RubyGems

割愛

Page 28: Software Development and RubyGems

よろしい、 ならば車輪の再発明だ

Page 29: Software Development and RubyGems

構想三秒

cron

rails rrails c

RDBMS

日時予約日時予約を永続化

※1定期実行予約があれば実行する

人生n回目の設計パターン

Page 30: Software Development and RubyGems

キモ

cron

rails rrails c

RDBMS

日時予約日時予約を永続化

※1定期実行予約があれば実行する

人生n回目の設計パターン

Page 31: Software Development and RubyGems

申請書

Page 32: Software Development and RubyGems

営業日

Page 33: Software Development and RubyGems

GUIが使えない場合はシェルを使う。

http://www.amazon.co.jp/dp/4274217620

Page 34: Software Development and RubyGems

GUIが使えない場合はシェルを使う。

http://www.slideshare.net/kdmsnr/xpjunkudo-20150626/61

Page 35: Software Development and RubyGems

どうやればできるかを考える

Page 36: Software Development and RubyGems

Ruby標準添付ライブラリ

Page 37: Software Development and RubyGems

http://docs.ruby-lang.org/ja/2.2.0/class/PStore.html

Page 38: Software Development and RubyGems

PStore

キモ

cron

rails rrails c

日時予約日時予約を永続化

※1定期実行予約があれば実行する

人生n回目の設計パターン

Page 39: Software Development and RubyGems
Page 40: Software Development and RubyGems

PStore

欲しかったものの前提

cron

rails rrails c

日時予約登録のみ

※1定期実行同一データへの同時更新はない

同一データへの同時更新がない

• 定期実行したら削除するくらいデータのライフサイクルが短い • 保存するモデルとしてリレーションシップが必要ない

Page 41: Software Development and RubyGems
Page 42: Software Development and RubyGems

自給自足

Page 43: Software Development and RubyGems

弱点多々

Page 44: Software Development and RubyGems

THE MAKING OF

A RubyGem

s

Page 45: Software Development and RubyGems

知見

Page 46: Software Development and RubyGems

実践投入された実装とされていない構想

Page 47: Software Development and RubyGems
Page 48: Software Development and RubyGems

社会実験

Page 49: Software Development and RubyGems

パターン

Page 50: Software Development and RubyGems
Page 51: Software Development and RubyGems

“パターンは発明するものではなく発見されるもの

『パターンハッチング』より

Page 52: Software Development and RubyGems
Page 53: Software Development and RubyGems

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

Page 54: Software Development and RubyGems

ActiveRecordっぽい振る舞い

Page 55: Software Development and RubyGems

有名な永続化のインタフェースで使える

Page 56: Software Development and RubyGems

•Create … save, create...

•Read … find, where...

•Update … save, update...

•Delete … destroy, delete...

先人の知恵による名前

Page 57: Software Development and RubyGems

コードレビューが増えたからこその より一層の名前重要

Page 58: Software Development and RubyGems

書ける速さ、読める速さ

Page 59: Software Development and RubyGems

先人の知恵による名前の作用

Page 60: Software Development and RubyGems

よく知られた名前で読むことができる

Page 61: Software Development and RubyGems

名前というインタフェースの重要性について

Page 62: Software Development and RubyGems
Page 63: Software Development and RubyGems

“http://i.loveruby.net/ja/rhg/book/intro.html

『Rubyソースコード完全解説』n ページより抜粋

静的解析とはつまりソースコードの解析だ。そしてソースコードの解析とは名前の調査である。ファイル名・関数名・変数名・型名・メンバ名など、プログラムは名前のかたまりだ。

Page 64: Software Development and RubyGems

おわりに

Page 65: Software Development and RubyGems

•書くときに名前付けの苦労が減る

•使い手への学習曲線を低くできる

•読むときに雰囲気で読める

よく知られた名前の再利用

Page 66: Software Development and RubyGems

“脳力を抑える『Lightweight Language MAGAZINE』より

Page 67: Software Development and RubyGems

TO����������� ������������������  BE����������� ������������������  CONTINUED

Enjoy Programming

Page 68: Software Development and RubyGems
Page 69: Software Development and RubyGems

テストデータ

Page 70: Software Development and RubyGems

https://github.com/koic/active_pstore

Page 71: Software Development and RubyGems

NG集

Page 72: Software Development and RubyGems

ドッグフードで得た知見https://ja.wikipedia.org/wiki/%E3%83%96%E3%83%AB%E3%83%89%E3%83%83%E3%82%B0#/media/File:Clyde_The_Bulldog.jpg

Page 73: Software Development and RubyGems
Page 74: Software Development and RubyGems

あれ?require しないと使えない…

> ActivePStore!NameError: uninitialized con!> require ‘active_pstore’!true!> ActivePStore!ActivePStore

Page 75: Software Development and RubyGems

bundler 使ってるのに require 書きたくないでござる!!!

絶対に require 書きたくないでござる!!!

Page 76: Software Development and RubyGems

https://rubygems.org/gems/active-pstore

Page 77: Software Development and RubyGems

http://guides.rubygems.org/name-your-gem/

Page 78: Software Development and RubyGems

名前重要 推奨重要