Slide 1

Slide 1 text

What, Why and When Refactoring Refactoring Yuya Saito @ Remixing

Slide 2

Slide 2 text

Remixing Welcome to

Slide 3

Slide 3 text

Yuya Saito @ Rich Media

Slide 4

Slide 4 text

Refactoring Refactoring ? ? ?

Slide 5

Slide 5 text

Agenda Agenda ϦϑΝΫλϦϯάͱ͸ͲΜͳ΋ͷͳͷ͔ ͳͥϦϑΝΫλϦϯάΛ͢Δඞཁ͕͋Δͷ͔ ͍ͭ΍Δ΋ͷͳͷ͔ What Why When

Slide 6

Slide 6 text

Refactoring: Improving the Design of Existing Code by Martin Fowler

Slide 7

Slide 7 text

What What ϦϑΝΫλϦϯάͱ͸

Slide 8

Slide 8 text

“The first draft of anything is shit.” — Ernest Hemingway

Slide 9

Slide 9 text

Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behaviour.

Slide 10

Slide 10 text

ϦϑΝΫλϦϯά ໊ࢺ ؍ଌͰ͖ΔৼΔ෣͍Λมߋ͢Δ͜ͱͳ͘ɺ ΑΓཧղ͠΍͘͢ɺมߋ͠΍͘͢ͳΔΑ͏ɺ ιϑτ΢ΣΞͷ಺෦తͳߏ଄Λมߋ͢Δ͜ͱɻ

Slide 11

Slide 11 text

ιʔείʔυΛΩϨΠʹ͢Δ͜ͱ tl;dr

Slide 12

Slide 12 text

ཧղ͠΍͘͢ɺ Point 1/2 มߋ͠΍͘͢͢Δɻ ιϑτ΢ΣΞΛ

Slide 13

Slide 13 text

؍ଌՄೳͳৼΔ෣͍Λมߋ͠ͳ͍ Point 2/2

Slide 14

Slide 14 text

Why Why ͳͥඞཁͳͷ͔

Slide 15

Slide 15 text

100% 100%

Slide 16

Slide 16 text

42 42

Slide 17

Slide 17 text

Improves the Design of Software Refactoring Refactoring ιϑτ΢ΣΞͷσβΠϯΛ޲্ͤ͞Δ

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

σβΠϯ͸࣌ؒͷܦաʹΑͬͯ ඼࣭͕Լ͕͍ͬͯ͘΋ͷ

Slide 20

Slide 20 text

ϓϩάϥϛϯάͷੈքͰ΋ ·ͬͨ͘ಉ͜͡ͱ͕ݴ͑Δ

Slide 21

Slide 21 text

มԽͷڱؒʹஔ͖๨Εͯ͠·ͬͨɺ ົͳʹ͓͍͕͢ΔίʔυΛݩʑͷσβΠϯʹ ߹Θͤͯॻ͖׵͑ΔͨΊʹଘࡏ͢Δɻ Refactoring Refactoring

Slide 22

Slide 22 text

Makes Software Easier to Understand Refactoring Refactoring ιϑτ΢ΣΞΛཧղ͢Δ͜ͱΛखॿ͚ͯ͘͠ΕΔ

Slide 23

Slide 23 text

Lazy Lazy

Slide 24

Slide 24 text

ॻ͍ͨίʔυʹ͓֮͑ͯ͘΂͖͜ͱ ͢΂ͯΛୗ͢ɻ ࢒ͨ͠͸ͣͷʮ͓֮͑ͯ͘΂͖ʯ͜ͱΛ ಡΈऔΕͳ͍ɻ u

Slide 25

Slide 25 text

ଞਓ͕ॻ͍ͨίʔυ΋ɺ ࣗ෼͕ॻ͍ͨίʔυ΋ཧղͰ͖ΔΑ͏ ॻ͖׵͑Δɻ Refactoring Refactoring

Slide 26

Slide 26 text

When When ͍ͭϦϑΝΫλϦϯάΛ͢Δ΂͖͔

Slide 27

Slide 27 text

ࣗ෼ͷ͍ͨ৔ॴ͸ɺͦ͜Λग़ͯߦ͘ͱ͖ɺ དྷͨ࣌ΑΓ΋͖Ε͍ʹ͠ͳ͚Ε͹ͳΒͳ͍ɻ — The Boy Scout Rule

Slide 28

Slide 28 text

ͲͷϓϩδΣΫτͰ΋ϦϑΝΫλϦϯά͕ ඞཁͰ͋Δͱ͍͏ೝ͕ࣝ͋Δɻ

Slide 29

Slide 29 text

Ͳ͏΍ͬͯϦϑΝΫλϦϯάͷ ࣌ؒΛ֬อ͢Δ͔ Problem is: Problem is:

Slide 30

Slide 30 text

Answer is Simple Answer is Simple ͦΜͳ࣌ؒ͸͍ͭ·Ͱͨͬͯ΋ ֬อͰ͖ͳ͍ɻ

Slide 31

Slide 31 text

ن໛ͷେখ͸͋ΕͲιʔείʔυʹ͸ ඞͣඒ͍͠ͱ͸ݴ͑ͳ͍෦෼͕͋Δ΋ͷɻ

Slide 32

Slide 32 text

ࣗ෼ͷ͍ͨ৔ॴ͸ɺͦ͜Λग़ͯߦ͘ͱ͖ɺ དྷͨ࣌ΑΓ΋͖Ε͍ʹ͠ͳ͚Ε͹ͳΒͳ͍ɻ — The Boy Scout Rule

Slide 33

Slide 33 text

ϦϑΝΫλϦϯά͸ظؒΛ ܾΊͯߦ͏΋ͷͰ͸ͳ͍ɻ

Slide 34

Slide 34 text

Rule of Three Rule of Three

Slide 35

Slide 35 text

1,2,_,_,_,_

Slide 36

Slide 36 text

1,2,3,_,_,_

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

“The first time you do something, you just do it. The second time you do something similar, you wince at the duplication, but you do the duplicate thing anyway. The third time you do something similar, you refactor.” — Don Roberts

Slide 39

Slide 39 text

·ͣ࢝Ίͷճ໨ʹԿ͔Λ͢Δ৔߹͸ɺ ͨͩͦΕΛ͢Δ͚ͩɻ ճ໨ʹԿ͔ࣅͨ͜ͱΛ͢Δ৔߹͸ɺ ॏෳʹද৘ΛಶΒͤͳ͕Β΋ɺ ͦͷॏෳ͍ͯ͠Δ͜ͱΛ͢Δɻ ճ໨ʹͦͷࣅͨԿ͔Λ͢Δࡍɺ ϦϑΝΫλΛߦ͏ɻ — Don Roberts

Slide 40

Slide 40 text

Outro Outro ·ͱΊ

Slide 41

Slide 41 text

೏ͬͨΒɺม͑Δɻ — The Rule of Baby Rearing

Slide 42

Slide 42 text

Code smells Code smells

Slide 43

Slide 43 text

೏͍Λ͔͗෼͚Δೳྗ͕ܦݧͱΑ͹ΕΔ΋ͷ

Slide 44

Slide 44 text

Take away Take away

Slide 45

Slide 45 text

1/2

Slide 46

Slide 46 text

2/2 ϦϑΝΫλϦϯά͸ ظؒΛܾΊͯߦ͏΋ͷͰ͸ͳ͘ɺ ௨ৗۀ຿ͷϫʔΫϑϩʔ಺Ͱߦ͏΋ͷͰ͢ɻ

Slide 47

Slide 47 text

The Long Goodbye by Raymond Chandler

Slide 48

Slide 48 text

“There is no trap so deadly as the trap you set for yourself.” — Philip Marlowe

Slide 49

Slide 49 text

“ࣗ෼Ͱࣗ෼ʹ࢓ֻ͚Δ᠘΄Ͳ ͨͪͷѱ͍᠘͸ͳ͍ɻ” — Philip Marlowe

Slide 50

Slide 50 text

Thank You! Thank You! @cssradar @cssradar