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
130
だったら、俺が代わりにやってやる / 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
340
Swift on Windows ファーストインプレッション / Swift on Windows First Impression
hironytic
0
590
iPadOSDC: Multiple Windows
hironytic
4
2.9k
SwiftのNeverとボトム型 / Never as a Bottom Type
hironytic
2
780
4000のワーニングと戦え!これは警告だ! / 4000 Warnings
hironytic
2
760
シンボリケート / Ore-con 2018 Summer
hironytic
3
1k
全部iOSにしゃべらせちゃえ! / iOSDC 2018 LT
hironytic
3
1.4k
ペダルのある生活 / The Pedal
hironytic
0
390
Cloud Firestore(の、スタブ)を作ってみた / Stubbing Cloud Firestore
hironytic
1
720
Other Decks in Programming
See All in Programming
Micro Frontends Unmasked: Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
250
Unlocking Python's Core Magic
leew
0
100
Micro Frontends for Java Microservices - dev2next 2024
mraible
PRO
0
150
Cloud Adoption Frameworkにみる組織とクラウド導入戦略(縮小版)
tomokusaba
1
120
Assembling the Future: crafting the missing pieces of the Ruby on Wasm puzzle
skryukov
0
120
CDKを活用した 大規模コンテナ移行 プロジェクトの紹介
yoyoyopg
0
220
pytest プラグインを開発して DRY に自動テストを書こう
inuatsu
2
220
Kotlin Multiplatform at Stable and Beyond (Kotlin Vienna, October 2024)
zsmb
2
270
DroidKaigi 2024 - You will 💜 Becoming a fullstack developer with your Android skills
brah
0
110
ROS 2のZenoh対応とZenohのROS 2対応
takasehideki
2
220
Iteratorでページネーションを実現する
sonatard
3
690
"noncopyable types" の使いどころについて考えてみた
andpad
0
110
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
93
5.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
36
2.1k
In The Pink: A Labor of Love
frogandcode
139
22k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
503
140k
The Mythical Team-Month
searls
218
43k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
27
7.5k
GraphQLの誤解/rethinking-graphql
sonatard
65
9.9k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
2
210
How to Think Like a Performance Engineer
csswizardry
16
1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
41
6.5k
Bootstrapping a Software Product
garrettdimon
PRO
304
110k
Navigating Team Friction
lara
183
14k
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Λ ա͢͜͝ͱ͕Ͱ͖·ͨ͠
͝ਗ਼ௌ͋Γ͕ͱ͏͟͝·ͨ͠