$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CASwift_11.pdf
Search
Shunsaku Miki
January 30, 2020
Programming
1
1.2k
CASwift_11.pdf
Shunsaku Miki
January 30, 2020
Tweet
Share
More Decks by Shunsaku Miki
See All by Shunsaku Miki
iOS12 New Notification
shunsakumiki
0
68
Other Decks in Programming
See All in Programming
大規模サイトリビルドの現場から:成功と失敗のリアルな教訓 / Site Rebuild,Real Lessons Learned from Successes and Failures_JJUG Fall 2024
techtekt
0
190
Cognitoが大型アップデート!Managed Loginとパスワードレスログインを実際に使ってみた@しむそくRadio Special Day1
tmhirai
2
130
Remix on Hono on Cloudflare Workers
yusukebe
1
380
5分ぐらいで分かる、トリミング機能の作り方
tsutsuitakumi
0
110
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
260
初めてDefinitelyTypedにPRを出した話
syumai
0
470
かんたんデザイン編集やってみた~「完全に理解した」までの道のり~
morit4ryo
1
100
「天気予報があなたに届けられるまで」 - NIFTY Tech Talk #22
niftycorp
PRO
0
130
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
2.9k
Welcome JSConf.jp 2024
yosuke_furukawa
PRO
0
2.8k
Functional Event Sourcing using Sekiban
tomohisa
0
120
物流システムにおけるリファクタリングとアーキテクチャの再構築 〜依存関係とモジュール分割の重要性〜
deeprain
1
240
Featured
See All Featured
A designer walks into a library…
pauljervisheath
204
24k
What's in a price? How to price your products and services
michaelherold
243
12k
Code Review Best Practice
trishagee
64
17k
Thoughts on Productivity
jonyablonski
67
4.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Building Applications with DynamoDB
mza
90
6.1k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Ruby is Unlike a Banana
tanoku
97
11k
Transcript
Amebaͷઃܭͱ͜Ε͔Β ~ΧΦε͔Βͷ٫ͱ࠶ͼΧΦεΛੜΈग़͞ͳ͍ྗʙ 2020/1/30
1.ࣗݾհ&ϓϩμΫτհ 2.ΧΦε͗ͨ͢ઃܭ 3.ϦΞʔΩςΫνϟ:yatteiki: 4.݁Ռͱະདྷ
ࣗݾհ&ϓϩμΫτհ
ࣗݾհˍϓϩμΫτհ • ࡾ ढ़࡞ • 2017த్ೖࣾ Ameba iOS։ൃϦʔμʔ • 2010ϦϦʔε
• Twitter/shun_sakuuu • Github/shun-mk
ΧΦε͗ͨ͢ઃܭ
ΧΦε͗ͨ͢ઃܭ • 2010ʹϦϦʔε͞Ε10Ҏ্ӡ༻Λ͍ͯ͠ΔΞϓϦ • ࣌ͷྲྀΕͷதͰͨ͘͞Μͷసظ • WebViewΞϓϦ͔ΒϑϧωΠςΟϒʹ • Objective-C͔ΒSwiftʹ •
વνʔϜͷϝϯόʔͷೖΕସΘΓܹ͍͠ • ࣌ͷྲྀΕͷதͰ࣌σϑΝΫτͩͱݴΘΕ͖ͯͨઃܭͨ͘͞Μ͋Δ • ΧΦε͔Β٫͠Α͏ͱͯ͠ૡ͍ͨࠟɻɻɻ
MVC • ଏʹݴ͏FatViewController • ΊͬͪΌViewControllerͰAPI௨৴ͯ͠Δ • ViewControllerͰAPI௨৴ͱ͔ॻ͍ͪΌͩΊͩΑʁ͍ͬͯ͏࣌ͷἤΓΛड͚ ͨͷ͔HogeHogeManagerͱ͔HogeHogeHelperͱ໋໊͔͔ΒԿ͢Δͷ͔Α͘ Θ͔Βͳ͍Ϋϥε͕API௨৴Λ࣋ͬͯͨΓ͢Δ •
વςετͳ͍
VIPER • Ұ෦VIPERͷߏͰ࡞ΒΕͯΔը໘͕͋Δ • ͓ͦΒ͘͜ΕAmebaΛΧΦε͔Β٫͢ΔͨΊʹઓͨ͠Ұͭͳͷ͔ͳʁ • ઃܭࢿྉ͕ͳ͘Ͳ͏͍͏ࢥͰͲ͏͍͏ߏʹͳ͍ͬͯΔͷ͔͕ඇৗʹ ͔ΓͮΒ͍ • વςετͳ͍
ΧΦε͗ͨ͢ઃܭ • ৽نը໘Λ࣮͢Δ࣌Ͳ͏͍͏ઃܭʹ͢Ε͍͍͔ຖճ0͔Βߟ͑Δͷ݁ߏେ ม • ͔͠ਓͦΕͧΕ͜Ε͕͍͍͍ͬͯ͏ͷ͕ҧ͏ͷͰϨϏϡʔίετΓΓ • ͦͷઃܭʹͨ͠ΤϯδχΞ͕͍ͳ͘ͳΔͱෛ࠴ײ͕ੌ͍ • ઃܭ͕΅ΜΓ&ີ݁߹&ςετಛʹͳ͘Կ͕ਖ਼ͷಈ͖ͳͷ͔Θ͔Βͳ͍ͷ
ࡾॏۤͰ༷มߋػೳՃʹ༨ʹ͕ൃੜ͢Δঢ়ଶʹ
ϦΞʔΩςΫνϟ:yatteiki:
ͬ͘͟Γͱͨ͠ํ • ࠓճͷϦΞʔΩςΫνϟͰࢦͨ͠࠷ऴܕMVVM ʴ Flux • ಋೖ͕ਐΜͰ͍ͳ͔ͬͨRxSwiftϦΞʔΩςΫνϟʹ߹ΘͤͯਐΊΔ • ͔ͤͬ͘ઃܭ͢͠ͳΒςετͷ࣮·Ͱߟ͑ΒΕͯΔઃܭʹ͍ͨ͠ •
ςετॻ͘ͳΒCIͷڥݟͯ͠ςετΛॻ͘͜ͱʹҙຯ͕͋Δঢ়ଶΛ࡞ Γ͍ͨ • ઃܭҊʹؔͯ͠ৗʹνʔϜͰ͢Γ߹ΘͤΛߦ͏(୭͔ҰਓͷઃܭΛօ͕ਅࣅ ͯ͠ॻ͚ͩ͘ͷঢ়ଶආ͚͍ͨ)
MVVM • Ұൠతʹࢥ͍ු͔ͿMVVMͱ΄΅มΘΒͳ͍ߏ • 1ը໘ͷϩδοΫ͕ෳࡶͳը໘͕ͦͦ͋͜͜Δͷͱෳͷը໘͕ಉظ͠ͳͯ͘ ͍͚ͳ͍Α͏ͳ༷͕ଟ͍Θ͚Ͱͳ͔ͬͨͷͰγϯϓϧͳMVVMΛ࠾༻ ͨ͠ • ViewͱViewModelͷbindingΛ͢ΔͨΊͷFrameworkRxSwiftΛ࠾༻(ࣾʹ ͓͚Δ࠾༻࣮ΛؑΈܾͯఆ)
MVVM • ॳظViewModelͷߏinitͰPublishSubjectΛੜ͠Observerͱ ObservableͷϓϩύςΟʹηοτͯ͠ߪಡ͢Δܗʹ͍ͯͨ͠ • ؆୯ͳը໘ͳΒˢͷ࣮ͰࠔΔ͜ͱಛʹͳ͍ • ViewModelͷIn-OutͷI/F͕࣮ऀʹҕͶΒΕ͓ͯΓϨϏϡʔίετ͕ංେԽ • ෳࡶͳॲཧ͕ೖͬͯ͘Δͱinit͕ஶ͘͠ංେԽ͠ϝϯςίετ͕ര૿ͨ͠
MVVM • ViewModelͷinitͰߦ͍ͬͯͨObservableͷՃAPI௨৴ɺViewදࣔ༻ͷ ModelͷTranslatorݺͼग़͠ΛUsecaseͱͯ͠Γग़͠ • ViewModelͷInputͱOutputΛProtocolʹΓग़͠In-OutͷI/FΛڞ௨Խ • ViewModelͷinitͰߦΘΕ͍ͯͨॲཧΛͦΕͧΕͷຖʹΓग़͠ංେԽ Λ͙ͱͱʹখ͍͞୯ҐͰςετ͕ॻ͚ΔΑ͏ʹ
Flux • MVVMͷΈͩͱ࣮ݱ͢ΔͷʹࡶԽ͢ΔΑ͏ͳ༷͕ग़͖ͯͨ • ϩάΠϯ/ϩάΞτʹΑͬͯΞϓϦશମͷঢ়ଶΛΓସ͑ͨΓɺλϒͷΑ͏ ͳը໘Ͱߋ৽௨ΛϒϩʔυΩϟετͨ͠Γ • ࠷ॳObserverͱObservableΛI/Fʹ࣋ͭSingletonͷΦϒδΣΫτΛར༻ͯ͠ ղܾ͍ͯ͠ΔՕॴ͕͋ͬͨԿ༷ʹѱ͍͜ͱ͕Ͱ͖ͯ͠·͏ͷͱεέʔ ϧ͢ΔΠϝʔδ͕ͳ͔ͬͨͨΊղܾ͔ͨͬͨ͠
Flux • Fluxര • σʔλϑϩʔFacebookͷFluxͱಉ༷ • ඇRxґଘ -> StoreViewModelͱbindͤͨ͞΄͏͕߹͕ྑ͍Օॴ͕͋ΔͷͰ StoreͷϕʔεΫϥεʹExtensionͰObservableʹม͢ΔॲཧΛՃ͍ͯ͠Δ
Flux • Fluxͷར༻ऀStoreͷΠϯελϯεΛੜ͠దٓbind͢Δ • SingletonͰ࣮͍ͯͨ࣌͠ͱҧ͍ར༻ऀଆ͕ඞཁͳΠϕϯτStateΛ࣋ͭ Store͚ͩΛݟΕ͍͍ͨΊෆཁͳObservableΛߪಡ͢Δ͜ͱΛ͛Δ • ංେԽ͠ଓ͚Δະདྷ͔͠ݟ͑ͳ͔ͬͨSingleton͔ΒඞཁʹԠͯ͡ܗΛม͑Δ StoreΛੜͰ͖ΔΑ͏ʹͳͬͨͷͰεέʔϧ͢Δײ •
σʔλϑϩʔ୯ํͳͷͰAPI௨৴͕ඞཁʹͳΔॲཧͰΩϨΠͳߏΛ อͭ͜ͱ͕Ͱ͖ΔΑ͏ʹ
ͨͩ͠
Flux • ར༻ՕॴͪΌΜͱߟ͑Δ͜ͱ • FluxΛར༻͢Δඞཁ͕ͳ͍ը໘FluxͰ࣮͢Δͱٯʹࡶʹͳͬͯ͠·͏ ՄೳੑΛሃΜͰ͍Δ • MVVMͰΩϨΠʹ࡞Εͳ͍ॲཧͷྲྀΕ͕͋ΔΑ͏ͳͱ͖ʹબࢶͱͯ͠ར ༻ •
ݸਓతʹNotificationCenterͱ͔ObserverύλʔϯͰຖճಠࣗͷศརΫϥε ࡞ΔΑΓஅવFlux
݁Ռͱະདྷ
ྑ͔ͬͨ • ৽࣮͘͠͞ΕΔը໘ͷ࡞Γ͕͋Δఔ౷Ұ͞Ε͍ͯΔͷϨϏϡʔίετ Λߟ͑ͯѹతʹྑ͍ • Ұਓ͕ઃܭ͢ΔͷͰͳ͘ɺνʔϜͰ͖ͬͪΓೝࣝΛ߹Θͤͳ͕ΒਐΊΔ ͜ͱͰઃܭΛߟ͑Δେࣄ͕͞ਁಁͨ͠ײ͕ͨ͡͠ • ઃܭͷࢿྉͳͲ͕ࣾͷυΩϡϝϯτʹ͞Ε͍ͯΔঢ়ଶΛ࡞Εͨ •
෭࣍తͰ͋Δ͕ςετͷࣄΛߟྀ͢ΔΑ͏ʹͳͬͨ͜ͱͰCIڥͷݟ͠ ͳͲਐΊΔ͜ͱ͕Ͱ͖ͨ(ϝϯςφʔ͕ଐਓԽ͍ͯͨ͠Jenkins͔ΒBitrise )
ΠϚΠνͩͬͨ • ࢼߦࡨޡ͠ͳ͕ΒͷϦΞʔΩςΫνϟͩͬͨͷͰίʔυͷதʹຊདྷඞཁͳ͍ ෛ࠴͕ͬͨ • ͕࣌ؒڐ͞ΕΔͳΒͬͱ৭ʑߟ͑Δ͖ͩͬͨ(init͕ංେԽ͢ΔϨΠ ϠʔΛҙࣝͨ͠ઃܭʣ • શը໘Λࠓճͷઃܭʹ͢ΔϚΠϧετʔϯͳͲҾ͚͓ͯΒͣࠜຊʹ͋ΔΧ Φε͕·ͩͳ͍ͤͯ͘ͳ͍
େࣄͳͷ͜ΕΒΛ౿·͑ͯ ͜Ε͔ΒͲ͏͍ͯ͘͠ͷ͔
͜Ε͔ΒͷAmebaͷઃܭ • ݱঢ়՝ͩͱײ͍ͯ͡Δͷ͕ViewModelΑΓཪଆͷ෦ͷ࡞Γ(Usecaseͱ͔ Repositoryͱ͔) • ࠓઃܭΛͨ͠ϝϯόʔ͕·ͩνʔϜʹἧ͍ͬͯΔͷͰடং͕อͨΕ͍ͯ Δ͚ͩ • શһ͍ͳ͘ͳͬͨ͋ͱΧΦεΛੜΈग़͢ةݥੑ·ͩ·ͩሃΜͰ͍Δ •
ͰԿΛ͢Δͷ͔ʁʁʁ
͜Ε͔ΒͷAmebaͷઃܭ • Layered Architectureͷߟ͑ํΛࢀߟʹऔΓೖΕ͍͖͍ͯͨ
͜Ε͔ΒͷAmebaͷઃܭ • Layered Architectureͷߟ͑ํଊ͑ํɺ࣮ࡍͷ࣮ʹࢸΔ·Ͱ৭ʑͳߟ͑ํ Λ࣋ͬͯΔਓ͕͍Δ • ݪཧओٛͰͳ͋͘͘·ͰAmebaͱͯ͠औΓೖΕΔͳΒͲͷܗ͕ཧͳͷ͔ Λߟ͍͖͍͑ͯͨ • ྫ͑EntityDomainͳͷ͔Dataͳͷ͔ɺ༷ʑͳߟ͑ํ͋Δͱࢥ͏
͕AmebaͷಛੑEmbedFrameworkͱͯ͠Γग़ͨ͠ͱ͖ʹෆՄղͳґଘঢ় ଶʹͳΒͳ͍Α͏ߟྀ͖͍ͯͨ͠
·ͱΊ • ͘ӡӦͯ͠ΔαʔϏεͩͱΧΦε͕ੜ·Εͯ͠·͏ͷํͳ͍͜ͱ • ݱঢ়ʹҤ͑Δ͚ͩ͡Όͳͯ͘Ή͠Ζ৳ͼ͠Ζͩͱଊ͑ΒΕΔϝϯόʔͱঢ়گ ͕ἧ͍ͬͯΕΨϯΨϯ͍ͬͯͬͨ΄͏͕͍͍͜ͱ͕͋Δ • ઃܭʹۜͷؙͳ͍ͷͰ৽͍͠ͷΛΩϟον্ͨ͠ͰαʔϏεಛੑʹ Ϛον͢ΕΨγΨγऔΓೖΕ͍ͯ͘ •
ಠΓΑ͕ΓͷઃܭͰͳ͘ઃܭͷνʔϜશମͰͷίϛοτํ๏ઃܭ͢Δ ඞཁ͕͋Δ
͋Γ͕ͱ͏͍͟͝·ͨ͠☺