Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

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

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

Hiron

May 16, 2020
Tweet

More Decks by Hiron

Other Decks in Programming

Transcript

  1. νϟϨϯδ౰೔ʙཌ೔ #PBSE7JFX 7JFX $POUSPMMFS ˣ͜ͷ࣌఺ͷϘʔυ #PBSE ϓϩτίϧ ʢ˞ҙຯ͸ͳ͔ͬͨʣ 3FWFSTJ -PHJDT

    FYUFOTJPO ˞placeDisk()͸Ξχϝʔ γϣϯͷΩϟϯηϧॲཧΛ ViewController͕͍࣋ͬͯ ͨΓͯ͠ɺ͍ͼͭͳঢ়ଶ IUUQTHJUIVCDPNIJSPOZUJDSFWFSTJJPTQVMM
  2. Ϧόʔγ൫ΛϞσϧͱϏϡʔʹ෼཭ ͷࣗ෼ͷϝϞ 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
  3. ϑΣʔζͱ͍͏ಠࣗ֓೦ 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? } ͷࣗ෼ͷϝϞ
  4. Ϟσϧͷ෦෼Λ3FEVY෩ʹ࣮૷ w ΊͬͪΌࢼߦࡨޡͨ͠  3FEVY͸஌ࣝͱͯ͠஌͍͚ͬͯͨͩͩͬͨʢ'MVY͸ܦݧ͋Γʣ w ຊՈ3FEVYͷαΠτͱɺؔ࿈ٕज़Λݟ௚ͨ͠Γ ‣ IUUQTSFEVYKTPSH ‣

    IUUQTHJUIVCDPNSFEVYKTSFEVYUIVOL ‣ IUUQTHJUIVCDPNSFEVYMPPQSFEVYMPPQ w ΊͬͪΌษڧʹͳΓ·ͨ͠ɹʜ͕͋·Γग़དྷʹࣗ৴͸ͳ͍