Slide 1

Slide 1 text

࿨ా୎ਓʢ!U@XBEBʣ αόϯφศΓ ࣗಈςετʹؔ͢Δ࿈ࡌͰಘΒΕͨ஌ݟͷ·ͱΊ ൛ 📷🙆 🙆 2JJUB$POGFSFODF .BZ

Slide 2

Slide 2 text

ΞοϓσʔτΛॏͶΔߨԋͷ೥݄൛Ͱ͢ʢ࿈ࡌୈճ·Ͱऩ࿥ʣ IUUQTTQFBLFSEFDLDPNUXBEB ίϥϜ࿈ࡌͷୈճ·Ͱऩ࿥͍ͯ͠·͢

Slide 3

Slide 3 text

ߨԋͷจࣈى͜͠౳΋ࠓޙެ։༧ఆͰ͢ ެ։͞ΕͨΒTQFBLFSEFDLͷಉҰ63-Ͱ ࢿྉΛΞοϓσʔτ͠·͢

Slide 4

Slide 4 text

t-wada t_wada twada 📷🙆 📹🙅 🙆 ࣗݾ঺հ #QiitaConference

Slide 5

Slide 5 text

ٕज़ॻͷग़൛ʹؔΘ͍ͬͯ·͢

Slide 6

Slide 6 text

αόϯφศΓʜʜʁ

Slide 7

Slide 7 text

IUUQTUXBEBIBUFOBCMPHKQFOUSZXEQSFTTTBWBOOBDPMVNO 8%#13&44ʹίϥϜΛ࿈ࡌ͍ͯ͠·͢

Slide 8

Slide 8 text

IUUQTUXBEBIBUFOBCMPHKQFOUSZXEQSFTTTBWBOOBDPMVNO 8%#13&44ʹίϥϜΛ࿈ࡌ͍ͯ͠·͢

Slide 9

Slide 9 text

ΑΖ͓͘͠ئ͍͠·͢ 📷🙆 🙆 2JJUB$POGFSFODF

Slide 10

Slide 10 text

ֶश༻ςετ ِཅੑͱِӄੑ ςεταΠζ ςετμϒϧ ςετϐϥϛου ࣗಈςετͷαΠζμ΢ϯઓུ 🦁 "HFOEB࿈ࡌ֤ճͷςʔϚ

Slide 11

Slide 11 text

ֶͼΛࣗಈςετͱͯ͠ॻ͘ ଈ࣌ੑͱ࠶ݱੑ

Slide 12

Slide 12 text

ֶशྫ1)1ͷ%BUF5JNFͱ%BUF5JNF*NNVUBCMF IUUQTXXXQIQOFUNBOVBMKBDMBTTEBUFUJNFJNNVUBCMFQIQ

Slide 13

Slide 13 text

/** * @test * @group learning */ public function DateTimeのaddは自身の状態を変更しつつ自身を返す(): void { $halloween = new \DateTime('2021-10-31'); $oneYear = \DateInterval::createFromDateString('1 year'); $halloween2022 = $halloween->add($oneYear); $this->assertSame($halloween, $halloween2022); $this->assertEquals('2022-10-31', $halloween->format('Y-m-d')); $this->assertEquals('2022-10-31', $halloween2022->format('Y-m-d')); } /** * @test * @group learning */ public function DateTimeImmutableのaddは自身の状態を変更せず新しい状態を伴う新しいインスタンスを返す(): void { $halloween = new \DateTimeImmutable('2021-10-31'); $oneYear = \DateInterval::createFromDateString('1 year'); $halloween2022 = $halloween->add($oneYear); $this->assertNotSame($halloween, $halloween2022); $this->assertEquals('2021-10-31', $halloween->format('Y-m-d')); $this->assertEquals('2022-10-31', $halloween2022->format('Y-m-d')); } %BUF5JNFͱ%BUF5JNF*NNVUBCMFͷҧ͍Λֶशςετʹ͢Δ ֶशςετʢֶͼ͕໨తͷςετʣΛ ݟ෼͚ΔͨΊʹ MFBSOJOHλάΛ͚͍ͭͯ·͢ ֶ͕͜͜ͼ ֶ͕͜͜ͼ

Slide 14

Slide 14 text

ٙ໰Λςετʹ͢Δ

Slide 15

Slide 15 text

/** * @test * @group learning */ public function 同じ時刻を指している場合はタイムゾーンが異なっても等価とみなされる(): void { $utc = new DateTimeImmutable('2021-12-24T15:00:00', new DateTimeZone('UTC')); $jst = new DateTimeImmutable('2021-12-25T00:00:00', new DateTimeZone('Asia/Tokyo')); $this->assertTrue($utc == $jst); } ٙ໰Λςετʹ͢Δ ςετʹฉ͍ͯΈΕ͹͍͍

Slide 16

Slide 16 text

ڻ͖Λςετʹ͢Δ ྫ͑͹ʜʜ

Slide 17

Slide 17 text

ί ϯ ε τ ϥ Ϋ λ ͸ Ұ ճ ͠ ͔ ݺ ΂ ͳ ͍ ͱ ࡨ ֮ ͠ ͯ ͍ ͨ ʁ ㅟ ㅟ ㅟ ㅟ ㅟ ㅟ ㅟ ㅟ ㅟ ㅟ ㅟ ㅟ ㅟ ㅟ ㅟ Ұ ମ ͍ ͭ ͔ Β ŠŠŠŠŠŠ

Slide 18

Slide 18 text

/** * @test * @group learning */ public function コンストラクタをもう一度呼ぶと破壊的変更ができてしまう(): void { $dt = new \DateTimeImmutable('2021-12-24'); $this->assertSame('2021-12-24', $dt->format('Y-m-d')); $dt->__construct('2022-01-01'); $this->assertSame('2022-01-01', $dt->format('Y-m-d')); } ͳΜʜʜͩͱʜʜʂʁ ໌ࣔతʹݺ΂ͯ͠·͏ ༨ஊ͜ͷςετίʔυΛ͖͔͚ͬʹQIQTSDʹJTTVFͱͯ͠ใࠂ͞Εɺٞ࿦͕ߦΘΕ·ͨ͠ɻ IUUQTHJUIVCDPNQIQQIQTSDJTTVFT ༨ஊ͜ͷςετίʔυΛ͖͔͚ͬʹ੩తղੳπʔϧ1)14UBOͱ1TBMNʹػೳఏҊ͕ߦΘΕɺ 1)14UBOʹ!NVOP@͞Μ͕࡞੒ͨ͠QVMMSFRVFTU͕࠾༻͞ΕɺϦϦʔε͞Ε·ͨ͠ɻ IUUQTHJUIVCDPNQIQTUBOQIQTUBOTSDQVMM

Slide 19

Slide 19 text

ֶश༻ςετ ِཅੑͱِӄੑ ςεταΠζ ςετμϒϧ ςετϐϥϛου ࣗಈςετͷαΠζμ΢ϯઓུ "HFOEB࿈ࡌ֤ճͷςʔϚ 🦁

Slide 20

Slide 20 text

ࣗಈςετͷ৴པੑΛ Ή͠͹Ήݱ৅Λཧղ͢Δ

Slide 21

Slide 21 text

ςετࣗಈԽͱاۀͷۀ੷ͷҼՌؔ܎ IUUQTXXXBNB[PODPKQEQ ςετͷࣗಈԽʹ͓͍ͯɺ*5ύϑΥʔϚϯεͷ 
 ༧ଌई౓ͱͳΓ͏Δ͜ͱ͕൑໌ͨ͠ͷ͸࣍ͷͭ ৴པੑͷߴ͍ࣗಈςετΛඋ͑Δ͜ͱ ։ൃऀओମͰड͚ೖΕςετΛ࡞੒ɾ؅ཧ͠ɺ 
 खݩͷ։ൃ؀ڥͰ؆୯ʹ࠶ݱɾमਖ਼Ͱ͖Δ͜ͱ ʰ-FBOͱ%FW0QTͷՊֶʱQʢ˞༁ΛҰ෦มߋʣ

Slide 22

Slide 22 text

IUUQTXXXBNB[PODPKQEQ ςετʹ߹֨ͨ͠ιϑτ΢ΣΞͰ͋Ε͹ϦϦʔεՄೳɺෆ߹֨Ͱ͋Ε͹ॏେͳ ෆ۩߹͕͋ΔɺͱνʔϜ͕֬৴Ͱ͖ΔΑ͏ͳςετΛ࣮ࢪ͍ͯ͠Δ͜ͱ ޡݕ஌ʢِཅੑGBMTFQPTJUJWFʣ΍ݟಀ͠ʢِӄੑGBMTFOFHBUJWFʣ͕ଟ ͘ɺ৴པੑʹ͚ܽΔςετεΠʔτ͕͋·Γʹ΋ଟ͗͢Δ ৴པ౓ͷߴ͍ςετεΠʔτΛ࡞Γ্͛Δܧଓతͳ౒ྗͱ 
 ౤ࢿ͸Ձ஋͕͋Δ ʰ-FBOͱ%FW0QTͷՊֶʱQʢ˞༁ΛҰ෦มߋʣ ৴པੑͷߴ͍ࣗಈςετΛඋ͑Δ͜ͱ

Slide 23

Slide 23 text

ِཅੑͱِӄੑ IUUQTHJIZPKQEFWTFSJBMTBWBOOBMFUUFS

Slide 24

Slide 24 text

ِཅੑͱِӄੑͷύλʔϯ w ِཅੑ w ੬͍ςετ CSJUUMFUFTU GSBHJMFUFTU w ৴པෆೳςετ fl BLZUFTU w ِӄੑ w ۭৼΓ w ΧόϨοδෆ଍ w ςετର৅ϩδοΫͷςετίʔυ΁ͷ࿙Εग़͠

Slide 25

Slide 25 text

// プロダクトコード class Item { // コンストラクタ割愛 tax_amount() { const rate = (this.tax_rate / 100); return (this.price / (1 + rate)) * rate; } } // テストコード it('税込価格から税額を返す', () => { const item = new Item('技評茶', 130, 8); const expected = (130 / (1 + (8 / 100))) * (8 / 100); assert.equal(item.tax_amount(), expected); }); ྫςετର৅ϩδοΫͷςετίʔυ΁ͷ࿙Εग़͠ ԁະຬͷ୺਺͕ൃੜ͢Δ όά͕͋Δ ςετίʔυͷํ΋ಉ͡ϩδοΫͰ ظ଴஋Λܭࢉ͍ͯ͠ΔͷͰ ςετ͕੒ޭͯ͠͠·͏

Slide 26

Slide 26 text

৴པෆೳੑʢ fl BLJOFTTʣ͕ʹ઀ۙ͢Δͱɺςετ͸Ձ஋Λࣦ͍࢝ΊΔ IUUQTXXXPSFJMMZDPKQCPPLT ʰ(PPHMFͷιϑτ΢ΣΞΤϯδχΞϦϯάʱQ

Slide 27

Slide 27 text

ֶश༻ςετ ِཅੑͱِӄੑ ςεταΠζ ςετμϒϧ ςετϐϥϛου ࣗಈςετͷαΠζμ΢ϯઓུ "HFOEB࿈ࡌ֤ճͷςʔϚ 🦁

Slide 28

Slide 28 text

ࣗಈςετͱ$*ʹϑΟοτ͢Δ ໌֬ͳςετ෼ྨج४

Slide 29

Slide 29 text

օ͞Μʹ͓࢕͍͠·͢ 🙋🙋🙋 σʔλϕʔεʹΞΫηε͢Δͷ͸Ϣχοτςετ :FT/P ωοτϫʔΫʹΞΫηε͢Δͷ͸Ϣχοτςετ :FT/P ϑΝΠϧʹΞΫηε͢Δͷ͸Ϣχοτςετ :FT/P ݱࡏ࣌ࠁʹΞΫηε͢Δͷ͸Ϣχοτςετ :FT/P ґଘઌͷΫϥεʹຊ෺Λ࢖͏ͷ͸Ϣχοτςετ :FT/P

Slide 30

Slide 30 text

IUUQTNBSUJOGPXMFSDPNCMJLJ6OJU5FTUIUNM 6OJU5FTUͷ6OJUͬͯԿʁ

Slide 31

Slide 31 text

5FTU4J[FΑΓᐆດ͞ͷগͳ͍෼ྨ

Slide 32

Slide 32 text

IUUQTUFTUJOHHPPHMFCMPHDPNUFTUTJ[FTIUNM 5FTU4J[F

Slide 33

Slide 33 text

4NBMM 
 ʢ୯Ұϓϩηεʣ .FEJVN 
 ʢ୯ҰϚγϯʣ -BSHF 
 ʢ੍໿ͳ͠ʣ 6OJU ൺ཰ େ͍ʹਪ঑ ආ͚͍͕ͨ ͔ͨ͠ͳ͍ͱ͖΋ ࠷ѱ͕ͩ Α͘ݟ͔͚Δ *OUFHSBUJPO ൺ཰ ॻ͚ΔͳΒ ίεύྑ͠ ී௨ Ͱ͖Ε͹ ආ͚͍ͨ && ൺ཰ ݪཧ্ෆՄೳʹ͍͕ۙ খ͍͞γεςϜͳΒՄೳʁ খ͍͞γεςϜ ͳΒՄೳ ී௨͔ͭ $6+ʹߜΓ͍ͨ 5FTU4DPQF 5FTU4J[F 5FTU4DPQFͱ5FTU4J[F

Slide 34

Slide 34 text

4NBMM 
 ʢ୯Ұϓϩηεʣ .FEJVN 
 ʢ୯ҰϚγϯʣ -BSHF 
 ʢ੍໿ͳ͠ʣ 6OJU ൺ཰ େ͍ʹਪ঑ ආ͚͍͕ͨ ͔ͨ͠ͳ͍ͱ͖΋ ࠷ѱ͕ͩ Α͘ݟ͔͚Δ *OUFHSBUJPO ൺ཰ ॻ͚ΔͳΒ ίεύྑ͠ ී௨ Ͱ͖Ε͹ ආ͚͍ͨ && ൺ཰ ݪཧ্ෆՄೳʹ͍͕ۙ খ͍͞γεςϜͳΒՄೳʁ খ͍͞γεςϜ ͳΒՄೳ ී௨͔ͭ $6+ʹߜΓ͍ͨ 5FTU4DPQF 5FTU4J[F 5FTU4DPQFͱ5FTU4J[F ίεύྑ͠ ίεύѱ͠

Slide 35

Slide 35 text

ֶश༻ςετ ِཅੑͱِӄੑ ςεταΠζ ςετμϒϧ ςετϐϥϛου ࣗಈςετͷαΠζμ΢ϯઓུ "HFOEB࿈ࡌ֤ճͷςʔϚ 🦁

Slide 36

Slide 36 text

஧࣮ੑͱܾఆੑͷ τϨʔυΦϑΛཧղ͢Δ

Slide 37

Slide 37 text

IUUQYVOJUQBUUFSOTDPN5FTU%PVCMFIUNM ςετμϒϧࣗಈςετ༻ͷِ෺

Slide 38

Slide 38 text

IUUQYVOJUQBUUFSOTDPN5FTU%PVCMFIUNM ςετμϒϧͷ෼ྨʢY651ʣ

Slide 39

Slide 39 text

ςετμϒϧͷར఺ͱ஫ҙ఺ IUUQTXXXBNB[PODPKQEQ w ར఺ w ςετ͠ʹ͍͘΋ͷΛςετՄೳʹ͢Δ w ςετͷ଎౓ͱܾఆੑΛ޲্ͤ͞Δ w ஫ҙ఺ w ςετ͕੬͘ͳΓɺมߋΛ๦͛Δʢར఺ͷཪฦ͠ʣ w ςετͷِӄੑΛট͘ʢࣗ࡞ࣗԋςετʣ

Slide 40

Slide 40 text

ֶश༻ςετ ِཅੑͱِӄੑ ςεταΠζ ςετμϒϧ ςετϐϥϛου ࣗಈςετͷαΠζμ΢ϯઓུ "HFOEB࿈ࡌ֤ճͷςʔϚ 🦁

Slide 41

Slide 41 text

ࣗಈςετͷ৴པੑΛ த௕ظతʹอͭ ࠷దͳόϥϯε

Slide 42

Slide 42 text

Ϣχοτ ΠϯςάϨʔγϣϯ && ίετ ஧࣮ੑ ଎౓ ςετέʔε਺ ߴ ௿ ௿ ߴ ܾఆੑ ςετϐϥϛου

Slide 43

Slide 43 text

ςετϐϥϛουͱΞΠεΫϦʔϜίʔϯΞϯνύλʔϯ IUUQTXBUJSNFMPOCMPHJOUSPEVDJOHUIFTPGUXBSFUFTUJOHJDFDSFBNDPOF

Slide 44

Slide 44 text

ࠞཚ͸ʮϢχοτʯʮΠϯςάϨʔγϣϯʯͷղऍͷϒϨ͔Βੜ͕ͪ͡

Slide 45

Slide 45 text

Ϣχοτ ΠϯςάϨʔγϣϯ && ίετ ஧࣮ੑ ଎౓ ςετέʔε਺ ߴ ௿ ௿ ߴ ܾఆੑ ϒϨͷগͳ͍ςετͷ෼ྨج४͸ʜʜʁ

Slide 46

Slide 46 text

ίετ ஧࣮ੑ ଎౓ ߴ ௿ ௿ ߴ ܾఆੑ ϒϨͷগͳ͍ςετͷ෼ྨج४ˠςεταΠζ 4NBMM .FEJVN -BSHF ςετέʔε਺

Slide 47

Slide 47 text

IUUQTXBUJSNFMPOCMPHJOUSPEVDJOHUIFTPGUXBSFUFTUJOHJDFDSFBNDPOF 4NBMM .FEJVN -BSHF खಈςετ Ͱ΋ɺଟ͘ͷݱ৔Ͱ͸ΞΠεΫϦʔϜίʔϯ͔Β࢝·ΔʢͦΕ͸ѱ͍͜ͱͰ͸ͳ͍ʣ

Slide 48

Slide 48 text

ֶश༻ςετ ِཅੑͱِӄੑ ςεταΠζ ςετμϒϧ ςετϐϥϛου ࣗಈςετͷαΠζμ΢ϯઓུ "HFOEB࿈ࡌ֤ճͷςʔϚ 🦁

Slide 49

Slide 49 text

Ͳ͏΍ͬͯΞΠεΫϦʔϜίʔϯΛϐϥϛουʹ͢Δ͔ IUUQTXBUJSNFMPOCMPHJOUSPEVDJOHUIFTPGUXBSFUFTUJOHJDFDSFBNDPOF 4NBMM .FEJVN -BSHF खಈςετ 4NBMM .FEJVN -BSHF

Slide 50

Slide 50 text

IUUQTXBUJSNFMPOCMPHJOUSPEVDJOHUIFTPGUXBSFUFTUJOHJDFDSFBNDPOF 4NBMM .FEJVN -BSHF खಈςετ -BSHF͔Β.FEJVN΁

Slide 51

Slide 51 text

IUUQYVOJUQBUUFSOTDPN5FTU%PVCMFIUNM -BSHF͔Β.FEJVN΁'BLF0CKFDU 'BLF͸ࣗಈςετ༻ͷ୅ସ࣮૷ɻ %ZOBNP%#ʹର͢Δ%ZOBNP%#MPDBM΍MPDBLTUBDL͕୅දྫɻ ίϯςφͰಈ࡞ͤ͞ΒΕΕ͹ςεταΠζ͕.FEJVNʹऩ·Δɻ

Slide 52

Slide 52 text

IUUQTXBUJSNFMPOCMPHJOUSPEVDJOHUIFTPGUXBSFUFTUJOHJDFDSFBNDPOF 4NBMM .FEJVN -BSHF खಈςετ .FEJVN͔Β4NBMM΁

Slide 53

Slide 53 text

.FEJVN͔Β4NBMM΁)VNCMF0CKFDU IUUQTXXXBNB[PODPKQEQ ςετ༰қੑΛԼ͍͛ͯΔཁૉΛബ͘੾Γग़͠ɺ ςετՄೳൣғΛ޿͘औΔجຊύλʔϯ

Slide 54

Slide 54 text

ΞΠεΫϦʔϜίʔϯ͔Βϐϥϛου΁ IUUQTXBUJSNFMPOCMPHJOUSPEVDJOHUIFTPGUXBSFUFTUJOHJDFDSFBNDPOF 4NBMM .FEJVN -BSHF खಈςετ 4NBMM .FEJVN -BSHF

Slide 55

Slide 55 text

ֶश༻ςετ ِཅੑͱِӄੑ ςεταΠζ ςετμϒϧ ςετϐϥϛου ࣗಈςετͷαΠζμ΢ϯઓུ 🦁 🦁 🦁 🦁 🦁 ͜Ε·Ͱͷ஌ݟΛ·ͱΊΔͱ

Slide 56

Slide 56 text

4NBMM .FEJVN -BSHF ίετ ஧࣮ੑ ଎౓ ςετέʔε਺ ߴ ௿ ௿ ߴ ܾఆੑ ·ͱΊςετμϒϧͰαΠζμ΢ϯͯ͠ɺ֤αΠζΛϐϥϛουܕʹ഑ஔ͠ɺςετશମͷ৴པੑΛҡ࣋͢Δ ςετμϒϧ ςετμϒϧ ςετ༰қੑઃܭ υϝΠϯઃܭ

Slide 57

Slide 57 text

͓ΘΓʹ

Slide 58

Slide 58 text

ࣦ৬ͷةػྑॻ͗͢Δ IUUQTCPPLNZOBWJKQFDQSPEVDUTEFUBJMJE

Slide 59

Slide 59 text

ࣦ৬ͷةػ͍͔ʹ΋ࢲͷݴ͍ͦ͏ͳ͜ͱΛݴ͏"* IUUQTUXJUUFSDPNLBXBTJNBTUBUVT

Slide 60

Slide 60 text

IUUQTHJIZPKQNBHB[JOFXEQSFTTTVTQFOEFE ൵͍͓͠஌Βͤ

Slide 61

Slide 61 text

͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ 📷🙆 🙆 2JJUB$POGFSFODF