96
ハイパーレガシーコード クリエイターだって テストを捨てたい 13519日日曜日

Shibuyarb20130515ver2

Embed Size (px)

Citation preview

Page 1: Shibuyarb20130515ver2

ハイパーレガシーコード  クリエイターだって

テストを捨てたい

13年5月19日日曜日

Page 2: Shibuyarb20130515ver2

あんただれ

13年5月19日日曜日

Page 3: Shibuyarb20130515ver2

名前:瀬宮 新

職業:自宅警備員 ハイパーレガシーコード  クリエイター

13年5月19日日曜日

Page 4: Shibuyarb20130515ver2

みなさん

13年5月19日日曜日

Page 5: Shibuyarb20130515ver2

こんばんは

13年5月19日日曜日

Page 6: Shibuyarb20130515ver2

家でコード書いてますか?

13年5月19日日曜日

Page 7: Shibuyarb20130515ver2

では

13年5月19日日曜日

Page 8: Shibuyarb20130515ver2

家でテストも書いてますか?

13年5月19日日曜日

Page 9: Shibuyarb20130515ver2

13年5月19日日曜日

Page 10: Shibuyarb20130515ver2

この前アプリ書いてたんですよ

13年5月19日日曜日

Page 11: Shibuyarb20130515ver2

本棚管理アプリ

13年5月19日日曜日

Page 12: Shibuyarb20130515ver2

一般公開したい

マルチユーザ対応

13年5月19日日曜日

Page 13: Shibuyarb20130515ver2

そうしたらコード汚いんですよ

13年5月19日日曜日

Page 14: Shibuyarb20130515ver2

どうにかしたい

13年5月19日日曜日

Page 15: Shibuyarb20130515ver2

リファクタしよう

13年5月19日日曜日

Page 16: Shibuyarb20130515ver2

コードをかえたので

13年5月19日日曜日

Page 17: Shibuyarb20130515ver2

テストも変更しなきゃ

13年5月19日日曜日

Page 18: Shibuyarb20130515ver2

テストがごちゃごちゃ

13年5月19日日曜日

Page 19: Shibuyarb20130515ver2

質の低いテストが大量

13年5月19日日曜日

Page 20: Shibuyarb20130515ver2

これはひどい

13年5月19日日曜日

Page 21: Shibuyarb20130515ver2

しかし量は多い

13年5月19日日曜日

Page 22: Shibuyarb20130515ver2

メッシュはバラバラ

13年5月19日日曜日

Page 23: Shibuyarb20130515ver2

カバレッジもよくない

13年5月19日日曜日

Page 24: Shibuyarb20130515ver2

どれを変更すれば・・・

13年5月19日日曜日

Page 25: Shibuyarb20130515ver2

正直 激おこ

13年5月19日日曜日

Page 26: Shibuyarb20130515ver2

どげんかせんと

13年5月19日日曜日

Page 27: Shibuyarb20130515ver2

13年5月19日日曜日

Page 28: Shibuyarb20130515ver2

過去の遺産

13年5月19日日曜日

Page 29: Shibuyarb20130515ver2

過去の成果物のレガシー化

13年5月19日日曜日

Page 30: Shibuyarb20130515ver2

そうだ

13年5月19日日曜日

Page 31: Shibuyarb20130515ver2

ひどいから全部捨てよう

13年5月19日日曜日

Page 32: Shibuyarb20130515ver2

実力も上がった

13年5月19日日曜日

Page 33: Shibuyarb20130515ver2

今ならもっとうまくやれる

13年5月19日日曜日

Page 34: Shibuyarb20130515ver2

変更部はコードをリファイン

13年5月19日日曜日

Page 35: Shibuyarb20130515ver2

テストコードもほぼ総入替

13年5月19日日曜日

Page 36: Shibuyarb20130515ver2

あれだけ書いたテストが無駄に

13年5月19日日曜日

Page 37: Shibuyarb20130515ver2

MOTTAINAI

13年5月19日日曜日

Page 38: Shibuyarb20130515ver2

13年5月19日日曜日

Page 39: Shibuyarb20130515ver2

ところで諸君

13年5月19日日曜日

Page 40: Shibuyarb20130515ver2

ユニットテストコードは滅ぼすべきだ

13年5月19日日曜日

Page 41: Shibuyarb20130515ver2

!?

13年5月19日日曜日

Page 42: Shibuyarb20130515ver2

13年5月19日日曜日

Page 43: Shibuyarb20130515ver2

そうじゃないんだ

13年5月19日日曜日

Page 44: Shibuyarb20130515ver2

@t_wada も言っている

13年5月19日日曜日

Page 45: Shibuyarb20130515ver2

実装が明白な場合はテストコードは書かなくてもよい

13年5月19日日曜日

Page 46: Shibuyarb20130515ver2

つまり実装が明白=簡単な実装

13年5月19日日曜日

Page 47: Shibuyarb20130515ver2

簡単な実装=テスト書かない複雑な実装=テスト書く

13年5月19日日曜日

Page 48: Shibuyarb20130515ver2

・・・

13年5月19日日曜日

Page 49: Shibuyarb20130515ver2

お前が思うのならそうなんだろお前の中では(ry

13年5月19日日曜日

Page 50: Shibuyarb20130515ver2

そうじゃない

13年5月19日日曜日

Page 51: Shibuyarb20130515ver2

そもそも

13年5月19日日曜日

Page 52: Shibuyarb20130515ver2

簡単な実装=テスト書かない複雑な実装=テスト書く

13年5月19日日曜日

Page 53: Shibuyarb20130515ver2

この話の問題点

13年5月19日日曜日

Page 54: Shibuyarb20130515ver2

境界があいまい

13年5月19日日曜日

Page 55: Shibuyarb20130515ver2

簡単と複雑の境界って?

13年5月19日日曜日

Page 56: Shibuyarb20130515ver2

さらに

13年5月19日日曜日

Page 57: Shibuyarb20130515ver2

悪魔のささやき

13年5月19日日曜日

Page 58: Shibuyarb20130515ver2

「締め切りが近い」「最近徹夜続きで」

13年5月19日日曜日

Page 59: Shibuyarb20130515ver2

「別にこのコード、  テスト書かなくても、

いいよね?」「だって簡単な実装だし」

13年5月19日日曜日

Page 60: Shibuyarb20130515ver2

そして、炎上へ

13年5月19日日曜日

Page 61: Shibuyarb20130515ver2

13年5月19日日曜日

Page 62: Shibuyarb20130515ver2

テストの目的って何か

13年5月19日日曜日

Page 63: Shibuyarb20130515ver2

不安をなくすこと

13年5月19日日曜日

Page 64: Shibuyarb20130515ver2

(開発者目線)

13年5月19日日曜日

Page 65: Shibuyarb20130515ver2

ではテストを書かなくても不安を感じない実装とは?

13年5月19日日曜日

Page 66: Shibuyarb20130515ver2

こんなの

13年5月19日日曜日

Page 67: Shibuyarb20130515ver2

# 円の面積を計算する

def compute_area_of_circle(半径) return 半径 * 半径 / 2end

13年5月19日日曜日

Page 68: Shibuyarb20130515ver2

あるいはこんなの

13年5月19日日曜日

Page 69: Shibuyarb20130515ver2

# 宅配便の荷物の高さを計算する

def 荷物の高さを計算する return 箱の高さend

13年5月19日日曜日

Page 70: Shibuyarb20130515ver2

このレベルまでは大丈夫

# 宅配便の荷物の3辺の合計を計算する

def 荷物の辺の合計を計算する return 高さ + 幅 + 奥行end

13年5月19日日曜日

Page 71: Shibuyarb20130515ver2

ここからは必要

def 荷物のサイズを判定する return compare_サイズ表(3辺の合計)end

13年5月19日日曜日

Page 72: Shibuyarb20130515ver2

13年5月19日日曜日

Page 73: Shibuyarb20130515ver2

ユーザのやりたいこと ・宅配便のサイズが知りたい ・料金が知りたい ・料金を払いたい

・・・

13年5月19日日曜日

Page 74: Shibuyarb20130515ver2

テストはミニユーザシナリオのレベルで行う

13年5月19日日曜日

Page 75: Shibuyarb20130515ver2

ユニットテストコードは書かない

13年5月19日日曜日

Page 76: Shibuyarb20130515ver2

そのためにメソッドは超シンプルに

13年5月19日日曜日

Page 77: Shibuyarb20130515ver2

テストを書く量が減る

13年5月19日日曜日

Page 78: Shibuyarb20130515ver2

開発早くなる

13年5月19日日曜日

Page 79: Shibuyarb20130515ver2

ウマー

13年5月19日日曜日

Page 80: Shibuyarb20130515ver2

13年5月19日日曜日

Page 81: Shibuyarb20130515ver2

ミニユーザシナリオのなにがおいしい?

13年5月19日日曜日

Page 82: Shibuyarb20130515ver2

説明タイム

13年5月19日日曜日

Page 83: Shibuyarb20130515ver2

ユーザの言葉でミニユーザシナリオ

13年5月19日日曜日

Page 84: Shibuyarb20130515ver2

その単位でミニユーザシナリオテスト

13年5月19日日曜日

Page 85: Shibuyarb20130515ver2

ミニユーザシナリオテスト

なにがおいしい?

13年5月19日日曜日

Page 86: Shibuyarb20130515ver2

コードの構造とドメインの構造の差異が小さい

13年5月19日日曜日

Page 87: Shibuyarb20130515ver2

機能の変更=

ミニユーザシナリオの変更

13年5月19日日曜日

Page 88: Shibuyarb20130515ver2

ミニユーザシナリオにあわせて変更されるテストが明らか

13年5月19日日曜日

Page 89: Shibuyarb20130515ver2

変更負荷の軽減

13年5月19日日曜日

Page 90: Shibuyarb20130515ver2

テスト量も低下する

13年5月19日日曜日

Page 91: Shibuyarb20130515ver2

スローテストの回避

13年5月19日日曜日

Page 92: Shibuyarb20130515ver2

13年5月19日日曜日

Page 93: Shibuyarb20130515ver2

なにより

13年5月19日日曜日

Page 94: Shibuyarb20130515ver2

変更のコストが下がる変更の不安もなくなる

13年5月19日日曜日

Page 95: Shibuyarb20130515ver2

開発=楽しい

13年5月19日日曜日

Page 96: Shibuyarb20130515ver2

楽しい開発で充実したハッカーライフを

13年5月19日日曜日