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
160
だったら、俺が代わりにやってやる / Swift Zoomin' Challenge
Swift Zoomin' の Fat View Controllerを倒せ! 報告会の発表スライドです。
Hiron
May 16, 2020
Tweet
Share
More Decks by Hiron
See All by Hiron
カンファレンス動画鑑賞会のススメ / Osaka.swift #1
hironytic
0
170
try! Swift Tokyo 2024 参加報告 / try! Swift Tokyo 2024 Report
hironytic
0
400
Swift on Windows ファーストインプレッション / Swift on Windows First Impression
hironytic
0
610
iPadOSDC: Multiple Windows
hironytic
4
3k
SwiftのNeverとボトム型 / Never as a Bottom Type
hironytic
2
810
4000のワーニングと戦え!これは警告だ! / 4000 Warnings
hironytic
2
790
シンボリケート / Ore-con 2018 Summer
hironytic
3
1k
全部iOSにしゃべらせちゃえ! / iOSDC 2018 LT
hironytic
3
1.5k
ペダルのある生活 / The Pedal
hironytic
0
420
Other Decks in Programming
See All in Programming
BEエンジニアがFEの業務をできるようになるまでにやったこと
yoshida_ryushin
0
190
.NETでOBS Studio操作してみたけど…… / Operating OBS Studio by .NET
skasweb
0
120
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
8
1.9k
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
300
AHC041解説
terryu16
0
360
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
930
Beyond ORM
77web
11
1.6k
盆栽転じて家具となる / Bonsai and Furnitures
aereal
0
1.8k
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
390
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
1.4k
PHPカンファレンス 2024|共創を加速するための若手の技術挑戦
weddingpark
0
140
AWSのLambdaで PHPを動かす選択肢
rinchoku
2
390
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
113
50k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
192
16k
Into the Great Unknown - MozCon
thekraken
34
1.6k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7.1k
Navigating Team Friction
lara
183
15k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
The Pragmatic Product Professional
lauravandoore
32
6.4k
Making Projects Easy
brettharned
116
6k
Site-Speed That Sticks
csswizardry
2
270
Being A Developer After 40
akosma
89
590k
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Λ ա͢͜͝ͱ͕Ͱ͖·ͨ͠
͝ਗ਼ௌ͋Γ͕ͱ͏͟͝·ͨ͠