Pro Yearly is on sale from $80 to $50! »

だったら、俺が代わりにやってやる / Swift Zoomin' Challenge

だったら、俺が代わりにやってやる / Swift Zoomin' Challenge

Swift Zoomin' の Fat View Controllerを倒せ! 報告会の発表スライドです。

473b12ebcfb79adfaef97796e94fc25c?s=128

Hiron

May 16, 2020
Tweet

Transcript

  1. ͩͬͨΒɺԶ͕ ୅ΘΓʹ΍ͬͯ΍Δʂ  4XJGU;PPNJOνϟϨϯδʙ'BU7JFX$POUSPMMFSΛ౗ͤʂʙ ใࠂձ

  2. "CPVU.F w ͻΖΜʢҰٶߒڭʣ w 5XJUUFS(JU)VC2JJUB 4MJEF4IBSF4QFBLFS%FDL ˠIJSPOZUJD w ಙౡࡏॅ w

    ීஈ͸'BU7JFX$POUSPMMFS ͱઓΘͣʹɺͲ͏෇͖߹ͬ ͍͔ͯ͘Λߟ͍͑ͯ·͢
  3. Ͱ͖͕͋ͬͨ΋ͷ w IUUQTHJUIVCDPNIJSPOZUJDSFWFSTJJPT w ΞʔΩςΫνϟύλʔϯɿ .77. 3FEVY w ࢖༻ϑϨʔϜϫʔΫɿ 6*,JUɺ$PNCJOF

  4. ϦϑΝΫλϦϯάΛ ͲͷΑ͏ʹਐΊ͍͔ͯͬͨ

  5. νϟϨϯδ౰೔ ͷࣗ෼ͷϝϞ w σΟεΫຕ਺Χ΢ϯτcountDisks(of:)  w σΟεΫຕ਺ͷଟ͍ํΛฦ͢sideWithMoreDisks()  w σΟεΫΛஔ͚Δ͔Ͳ͏͔ௐ΂ΔcanPlaceDisk(_:atX:y:)

     w σΟεΫΛஔ͚Δ৔ॴΛฦ͢validMoves(for:)  w σΟεΫΛஔ͘placeDisk(_:atX:y:animated:completion:)
  6. νϟϨϯδ౰೔ʙཌ೔ #PBSE7JFX 7JFX $POUSPMMFS ˣ͜ͷ࣌఺ͷϘʔυ #PBSE ϓϩτίϧ ʢ˞ҙຯ͸ͳ͔ͬͨʣ 3FWFSTJ -PHJDT

    FYUFOTJPO ˞placeDisk()͸Ξχϝʔ γϣϯͷΩϟϯηϧॲཧΛ ViewController͕͍࣋ͬͯ ͨΓͯ͠ɺ͍ͼͭͳঢ়ଶ IUUQTHJUIVCDPNIJSPOZUJDSFWFSTJJPTQVMM
  7. ಘΒΕͨ΋ͷ w ʮͳΜ͔΍ͬͨͬͨʯͱ͍͏ຬ଍ײ

  8. Ϧόʔγ൫ΛϞσϧͱϏϡʔʹ෼཭ ͷࣗ෼ͷϝϞ BoardView΋ ͍࣋ͬͯΔػೳ 3FWFSTJ-PHJDT ͷػೳ struct CellChange: Hashable {

    var x: Int var y: Int var disk: Disk? } struct Board { ... mutating func placeDisk(_ disk: Disk, atX x: Int, y: Int) throws -> [CellChange] { ... } } IUUQTHJUIVCDPNIJSPOZUJDSFWFSTJJPTQVMM
  9. ಘΒΕͨ΋ͷ w Ϙʔυͷঢ়ଶͱը໘Λ੾Γ཭ͤͨ w Ϧόʔγͷϧʔϧʹجͮ͘มߋ͔͠ߦ͑ͳ͍҆શ ੑʢྫ͑͹ͻͬ͘ΓฦΒͳ͍ͱ͜ΖʹσΟεΫΛ ஔ͘͜ͱ͸Ͱ͖ͳ͍ʣ w 3FWFSTJ-PHJDTͷςετίʔυ

  10. ήʔϜਐߦΛ෼཭͍͕ͨ͠ʜ w ͳΜͱͳ͘.77. w ϘʔυҎ֎ͷ6*ͷଘࡏ Λ๨Ε͍ͯΔ w ਐߦͷྲྀΕ͕੔ཧͰ͖ͯ ͍ͳ͍ w

    Ξχϝʔγϣϯ΍Ξϥʔ τ͸7JFX૚ͷ੹຿ͱߟ ͍͑ͯΔ ͷࣗ෼ͷϝϞ
  11. ήʔϜਐߦͷྲྀΕΛ੔ཧ ͷࣗ෼ͷϝϞ

  12. ը໘ 7JFX ͷೖग़ྗ΋੔ཧ ͷࣗ෼ͷϝϞ

  13. ήʔϜͷہ໘͕ঢ়ଶભҠ͢Δͱߟ͑ͨ ͷࣗ෼ͷϝϞ

  14. ঢ়ଶભҠͱ͍͑͹ʜ3FEVY ͷࣗ෼ͷϝϞ .PEFM 7JFX 7JFX.PEFM 3FEVY

  15. Ϟσϧͷ෦෼Λ3FEVY෩ʹ࣮૷ w ΊͬͪΌࢼߦࡨޡͨ͠  3FEVY͸஌ࣝͱͯ͠஌͍͚ͬͯͨͩͩͬͨʢ'MVY͸ܦݧ͋Γʣ

  16. ϑΣʔζͱ͍͏ಠࣗ֓೦ public protocol Reducer { /// ΞΫγϣϯʹԠͯ͡ঢ়ଶΛมߋ͠·͢ɻ /// - Parameters:

    /// - state: มߋલͷঢ়ଶͰ͢ɻ /// - action: ঢ়ଶมߋΛཁٻ͢ΔΞΫγϣϯͰ͢ɻ /// - Returns: มߋޙͷঢ়ଶΛฦ͠·͢ɻ static func reduce(state: State, action: Action) -> State } public protocol Phase: Reducer, Hashable, CustomStringConvertible { /// ϑΣʔζछผͰ͢ɻ var kind: PhaseKind { get } /// ผͷϑΣʔζ͔Β͜ͷϑΣʔζʹભҠ͢Δͱ͖ʹݺ͹Ε·͢ɻ /// ඞཁʹԠͯ͡αϯΫΛฦ͢͜ͱ͕Ͱ͖·͢ɻ /// - Parameters: /// - previousPhase: ҎલͷϑΣʔζ͕౉͞Ε·͢ɻ static func onEnter(previousPhase: AnyPhase) -> Thunk? /// ͜ͷϑΣʔζ͔ΒผͷϑΣʔζʹભҠ͢Δͱ͖ʹݺ͹Ε·͢ɻ /// ඞཁʹԠͯ͡αϯΫΛฦ͢͜ͱ͕Ͱ͖·͢ɻ /// - Parameters: /// - state: ݱࡏͷঢ়ଶͰ͢ɻ /// - nextPhase: ࣍ͷϑΣʔζ͕౉͞Ε·͢ɻ static func onExit(nextPhase: AnyPhase) -> Thunk? } ͷࣗ෼ͷϝϞ
  17. Ϟσϧͷ෦෼Λ3FEVY෩ʹ࣮૷ w ΊͬͪΌࢼߦࡨޡͨ͠  3FEVY͸஌ࣝͱͯ͠஌͍͚ͬͯͨͩͩͬͨʢ'MVY͸ܦݧ͋Γʣ w ຊՈ3FEVYͷαΠτͱɺؔ࿈ٕज़Λݟ௚ͨ͠Γ ‣ IUUQTSFEVYKTPSH ‣

    IUUQTHJUIVCDPNSFEVYKTSFEVYUIVOL ‣ IUUQTHJUIVCDPNSFEVYMPPQSFEVYMPPQ w ΊͬͪΌษڧʹͳΓ·ͨ͠ɹʜ͕͋·Γग़དྷʹࣗ৴͸ͳ͍
  18. Ϟσϧͷ෦෼ͷ࣮૷͕ͻͱͱ͓ΓऴΘΓʜ ΄Μͷগ͠ςετίʔυΛॻ͍ͯಈ࡞Λ֬ೝ ࢒Γͷςετ͸͍ͬͨΜอཹͯ͠ɺ7JFX.PEFMͷ࣮૷ʹ IUUQTHJUIVCDPNIJSPOZUJDSFWFSTJJPTQVMM

  19. 7JFX.PEFMΛ࣮૷ɺͦͯ͠ʜ 7JFX$POUSPMMFSͱ΋઀ଓ IUUQTHJUIVCDPNIJSPOZUJDSFWFSTJJPTQVMM

  20. ࣮ࡍʹಈ͔ͤͯ༡΂Δ

  21. ಾػೳͷര஀ w ஔ͚ͳ͍ͱ͜Ζʹஔ͜͏ͱ͢Δͱ w ίϯϐϡʔλʔ͕উखʹߟ͑ͯஔ͍ ͯ͘ΕΔ w ʮͩͬͨΒɺ ɹԶ͕୅ΘΓʹ΍ͬͯ΍Δʂʯػೳ ʢ˞όάʣ

  22. Ϟσϧ૚ͷςετΛॆ࣮ͤ͞Δ w ঢ়ଶભҠਤΛॻ ͖ͳ͓ͨ͠ w ͜ΕΛݟͳ͕Β ςετέʔεΛ ࡞ͬͨ ʙͷࣗ෼ͷϝϞ

  23. ʮͩͬͨΒɺԶ͕୅ΘΓʹ΍ͬͯ΍Δʯػೳ

  24. .PEFMͱ7JFX.PEFMͱͷࠩ w .PEFMʹ͸7JFXͷߏ଄Λҙࣝͨ͠4UBUF͸͍࣋ͨͤͯͳ ͍ʢྫɿλʔϯදࣔ΍উഊදࣔʹ %JTL7JFXΛ࢖͏ͳͲʣ w 7JFX.PEFM͸7JFXͷߏ଄Λڧ͘ҙࣝͯ͠ɺͳΔ΂ͦ͘ͷ ··όΠϯσΟϯάͰ͖ΔΑ͏ʹσʔλΛՃ޻ w 7JFXͱ7JFX.PEFMΛ෼͚Δҙຯ͸ʁ

    ˠςετ͕ॻ͚Δ 7JFX.PEFMͷςετΛॻ͍͍ͯͳ͔ͬͨ
  25. ָ͍͠(8Λ ա͢͜͝ͱ͕Ͱ͖·ͨ͠

  26. ͝ਗ਼ௌ͋Γ͕ͱ͏͟͝·ͨ͠