Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
だったら、俺が代わりにやってやる / Swift Zoomin' Challenge
Search
Hiron
May 16, 2020
Programming
0
140
だったら、俺が代わりにやってやる / Swift Zoomin' Challenge
Swift Zoomin' の Fat View Controllerを倒せ! 報告会の発表スライドです。
Hiron
May 16, 2020
Tweet
Share
More Decks by Hiron
See All by Hiron
try! Swift Tokyo 2024 参加報告 / try! Swift Tokyo 2024 Report
hironytic
0
360
Swift on Windows ファーストインプレッション / Swift on Windows First Impression
hironytic
0
600
iPadOSDC: Multiple Windows
hironytic
4
2.9k
SwiftのNeverとボトム型 / Never as a Bottom Type
hironytic
2
790
4000のワーニングと戦え!これは警告だ! / 4000 Warnings
hironytic
2
770
シンボリケート / Ore-con 2018 Summer
hironytic
3
1k
全部iOSにしゃべらせちゃえ! / iOSDC 2018 LT
hironytic
3
1.5k
ペダルのある生活 / The Pedal
hironytic
0
400
Cloud Firestore(の、スタブ)を作ってみた / Stubbing Cloud Firestore
hironytic
1
740
Other Decks in Programming
See All in Programming
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
470
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
Click-free releases & the making of a CLI app
oheyadam
2
110
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
910
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.4k
役立つログに取り組もう
irof
28
9.6k
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
870
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
最新TCAキャッチアップ
0si43
0
140
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
220
Featured
See All Featured
Producing Creativity
orderedlist
PRO
341
39k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
GraphQLとの向き合い方2022年版
quramy
43
13k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Making Projects Easy
brettharned
115
5.9k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
For a Future-Friendly Web
brad_frost
175
9.4k
Transcript
ͩͬͨΒɺԶ͕ ΘΓʹͬͯΔʂ 4XJGU;PPNJOνϟϨϯδʙ'BU7JFX$POUSPMMFSΛͤʂʙ ใࠂձ
"CPVU.F w ͻΖΜʢҰٶߒڭʣ w 5XJUUFS(JU)VC2JJUB 4MJEF4IBSF4QFBLFS%FDL ˠIJSPOZUJD w ಙౡࡏॅ w
ීஈ'BU7JFX$POUSPMMFS ͱઓΘͣʹɺͲ͏͖߹ͬ ͍͔ͯ͘Λߟ͍͑ͯ·͢
Ͱ͖͕͋ͬͨͷ w IUUQTHJUIVCDPNIJSPOZUJDSFWFSTJJPT w ΞʔΩςΫνϟύλʔϯɿ .77. 3FEVY w ༻ϑϨʔϜϫʔΫɿ 6*,JUɺ$PNCJOF
ϦϑΝΫλϦϯάΛ ͲͷΑ͏ʹਐΊ͍͔ͯͬͨ
νϟϨϯδ ͷࣗͷϝϞ w σΟεΫຕΧϯτcountDisks(of:) w σΟεΫຕͷଟ͍ํΛฦ͢sideWithMoreDisks() w σΟεΫΛஔ͚Δ͔Ͳ͏͔ௐΔcanPlaceDisk(_:atX:y:)
w σΟεΫΛஔ͚ΔॴΛฦ͢validMoves(for:) w σΟεΫΛஔ͘placeDisk(_:atX:y:animated:completion:)
νϟϨϯδʙཌ #PBSE7JFX 7JFX $POUSPMMFS ˣ͜ͷ࣌ͷϘʔυ #PBSE ϓϩτίϧ ʢ˞ҙຯͳ͔ͬͨʣ 3FWFSTJ -PHJDT
FYUFOTJPO ˞placeDisk()Ξχϝʔ γϣϯͷΩϟϯηϧॲཧΛ ViewController͕͍࣋ͬͯ ͨΓͯ͠ɺ͍ͼͭͳঢ়ଶ IUUQTHJUIVCDPNIJSPOZUJDSFWFSTJJPTQVMM
ಘΒΕͨͷ w ʮͳΜ͔ͬͨͬͨʯͱ͍͏ຬײ
Ϧόʔγ൫ΛϞσϧͱϏϡʔʹ ͷࣗͷϝϞ 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
ಘΒΕͨͷ w Ϙʔυͷঢ়ଶͱը໘ΛΓͤͨ w Ϧόʔγͷϧʔϧʹجͮ͘มߋ͔͠ߦ͑ͳ͍҆શ ੑʢྫ͑ͻͬ͘ΓฦΒͳ͍ͱ͜ΖʹσΟεΫΛ ஔ͘͜ͱͰ͖ͳ͍ʣ w 3FWFSTJ-PHJDTͷςετίʔυ
ήʔϜਐߦΛ͍͕ͨ͠ʜ w ͳΜͱͳ͘.77. w ϘʔυҎ֎ͷ6*ͷଘࡏ ΛΕ͍ͯΔ w ਐߦͷྲྀΕ͕ཧͰ͖ͯ ͍ͳ͍ w
ΞχϝʔγϣϯΞϥʔ τ7JFXͷͱߟ ͍͑ͯΔ ͷࣗͷϝϞ
ήʔϜਐߦͷྲྀΕΛཧ ͷࣗͷϝϞ
ը໘ 7JFX ͷೖग़ྗཧ ͷࣗͷϝϞ
ήʔϜͷہ໘͕ঢ়ଶભҠ͢Δͱߟ͑ͨ ͷࣗͷϝϞ
ঢ়ଶભҠͱ͍͑ʜ3FEVY ͷࣗͷϝϞ .PEFM 7JFX 7JFX.PEFM 3FEVY
Ϟσϧͷ෦Λ3FEVY෩ʹ࣮ w ΊͬͪΌࢼߦࡨޡͨ͠ 3FEVYࣝͱ͍͚ͯͬͯͨͩͩͬͨ͠ʢ'MVYܦݧ͋Γʣ
ϑΣʔζͱ͍͏ಠࣗ֓೦ 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? } ͷࣗͷϝϞ
Ϟσϧͷ෦Λ3FEVY෩ʹ࣮ w ΊͬͪΌࢼߦࡨޡͨ͠ 3FEVYࣝͱ͍͚ͯͬͯͨͩͩͬͨ͠ʢ'MVYܦݧ͋Γʣ w ຊՈ3FEVYͷαΠτͱɺؔ࿈ٕज़Λݟͨ͠Γ ‣ IUUQTSFEVYKTPSH ‣
IUUQTHJUIVCDPNSFEVYKTSFEVYUIVOL ‣ IUUQTHJUIVCDPNSFEVYMPPQSFEVYMPPQ w ΊͬͪΌษڧʹͳΓ·ͨ͠ɹʜ͕͋·Γग़དྷʹࣗ৴ͳ͍
Ϟσϧͷ෦ͷ࣮͕ͻͱͱ͓ΓऴΘΓʜ ΄Μͷগ͠ςετίʔυΛॻ͍ͯಈ࡞Λ֬ೝ Γͷςετ͍ͬͨΜอཹͯ͠ɺ7JFX.PEFMͷ࣮ʹ IUUQTHJUIVCDPNIJSPOZUJDSFWFSTJJPTQVMM
7JFX.PEFMΛ࣮ɺͦͯ͠ʜ 7JFX$POUSPMMFSͱଓ IUUQTHJUIVCDPNIJSPOZUJDSFWFSTJJPTQVMM
࣮ࡍʹಈ͔ͤͯ༡Δ
ಾػೳͷര w ஔ͚ͳ͍ͱ͜Ζʹஔ͜͏ͱ͢Δͱ w ίϯϐϡʔλʔ͕উखʹߟ͑ͯஔ͍ ͯ͘ΕΔ w ʮͩͬͨΒɺ ɹԶ͕ΘΓʹͬͯΔʂʯػೳ ʢ˞όάʣ
ϞσϧͷςετΛॆ࣮ͤ͞Δ w ঢ়ଶભҠਤΛॻ ͖ͳ͓ͨ͠ w ͜ΕΛݟͳ͕Β ςετέʔεΛ ࡞ͬͨ ʙͷࣗͷϝϞ
ʮͩͬͨΒɺԶ͕ΘΓʹͬͯΔʯػೳ
.PEFMͱ7JFX.PEFMͱͷࠩ w .PEFMʹ7JFXͷߏΛҙࣝͨ͠4UBUF͍࣋ͨͤͯͳ ͍ʢྫɿλʔϯදࣔউഊදࣔʹ %JTL7JFXΛ͏ͳͲʣ w 7JFX.PEFM7JFXͷߏΛڧ͘ҙࣝͯ͠ɺͳΔͦ͘ͷ ··όΠϯσΟϯάͰ͖ΔΑ͏ʹσʔλΛՃ w 7JFXͱ7JFX.PEFMΛ͚Δҙຯʁ
ˠςετ͕ॻ͚Δ 7JFX.PEFMͷςετΛॻ͍͍ͯͳ͔ͬͨ
ָ͍͠(8Λ ա͢͜͝ͱ͕Ͱ͖·ͨ͠
͝ਗ਼ௌ͋Γ͕ͱ͏͟͝·ͨ͠