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
MVVM
Search
Takuma Shimizu
June 24, 2023
Programming
0
37
MVVM
Takuma Shimizu
June 24, 2023
Tweet
Share
More Decks by Takuma Shimizu
See All by Takuma Shimizu
Swift Attributes
hokuron
0
360
Peek in Calendar implementation of swift-foundation
hokuron
0
140
Summon Rust from Swift
hokuron
0
620
Opaque Result Type in Swift with Rust
hokuron
0
130
Generalized accessors
hokuron
0
63
Ownership of Swift as seen from iteration and Rust
hokuron
1
620
Clean Architecture 3
hokuron
0
31
Clean Architecture 2
hokuron
0
50
Create MLで犬と猫の肉球を学習
hokuron
0
85
Other Decks in Programming
See All in Programming
快速入門可觀測性
blueswen
0
410
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
260
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
280
Effective Signals in Angular 19+: Rules and Helpers
manfredsteyer
PRO
0
130
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
260
nekko cloudにおけるProxmox VE利用事例
irumaru
3
460
CloudflareStack でRAGに入門
asahiiwm
0
100
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
110
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
300
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
200
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
280
Featured
See All Featured
Practical Orchestrator
shlominoach
186
10k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Code Reviewing Like a Champion
maltzj
521
39k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Site-Speed That Sticks
csswizardry
2
190
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
A designer walks into a library…
pauljervisheath
205
24k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Docker and Python
trallard
42
3.1k
Code Review Best Practice
trishagee
65
17k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Transcript
MVVM
͜Ε͔ΒMVVMʹ͍ͭͯΘ͍Θ͍͢Δલʹ MVVM͕ੜΈग़͞ΕͨܦҢΛ͍ ͦΕ͕͠ಘͨ͜ͱΛΓ Έͳ͞ΜͷٞͷϕʔεΛͭ͘Γ͍ͨ
MVVMʹࢸΔ·Ͱ w 5.7& ݪॳ.7$ w .7$ w .7$ "QQMJDBUJPO.PEFM
w ݪॳ.71 w .71 w .7$ 1SFTFOUBUJPO.PEFM w.77. w .717. w ʜ Cocoa MVCग़ͯ͜ͳ͍Αʂ 👉
TMVE (ݪॳMVC) w ϓϨθϯςʔγϣϯ (6*දݱ ͱϞσϧ σʔλͱͦͷৼΔ͍ ͷ w ύλʔϯԽ͞Εͨ.7$ͱޙଓͷύλʔϯ
(6*ΞʔΩςΫνϟʔ ʹڧ͘Ө ڹΛ༩͑ͨ
MVC͕͠ಘͨ͜ͱ w ϓϨθϯςʔγϣϯͱϞσϧͷΛ͞Βʹൃల w 0CTFSWFSύλʔϯʹΑΔσʔλͷಉظํ๏Λཱ֬
MVC͕ͨ͠՝ w 7JFXͷϩδοΫͱঢ়ଶͷஔ͖ॴ͕ෆ໌ྎ w ࣌ͷ(6*୯७Ͱݱ΄ͲϦονͰͳ͔ͬͨͨΊɺେ͖ͳʹ ͳΒͳ͔ͬͨ w ˠ"QQMJDBUJPO.PEFM
MVC + Application Model • View - ModelؒͰͷతͳมߋͷࢹɾ௨͔Β • View
- Application Model - ModelʹΑΔؒతͳࢹɾ௨ • Application ModelModelͱͯ͠ͷଆ໘͕ڧ͍ • View - Modelؒͷσʔλͷදݱมߦ͏ • → ViewͷϩδοΫͱঢ়ଶͷஔ͖ॴͱͯ͠ػೳ
Application Modelͷ՝ • Observerύλʔϯ͕ద༻Ͱ͖ΔͷɺModelʹଘࡏ͢ΔσʔλͷΈ • Viewಠࣗͷঢ়ଶɺObserverύλʔϯʹΑΔࢹɾ௨Λద༻Ͱ͖ͳ͍ • ModelతͳଘࡏͰ͋ΔApplication Model͕ViewΛ͍͡Δ͜ͱʹ… •
ྫɿview.textField.textColor = .red Λ࣮ߦ͢ΔΑ͏ͳͷ • ObserverύλʔϯʹΑΔ੍ΛಀΕɺApplication Model͕ංେԽ
ݪॳMVP • MVCͷਖ਼౷ਐԽͷงғؾ • ݱͷMVPͱҟͳΔඇৗʹڵຯਂ͍ߏ • Application Modelͷ՝ղܾͱ͋·Γؔͳ͍ͷͰׂѪ • વɺݱͷMVPʹେ͖ͳӨڹΛ༩͍͑ͯΔ
MVP • MVVMͱฒΜͰApplication Modelͷ՝Λղܾͨ͠Ұͭͷύλʔϯ • MVVMʹӨڹΛ༩͑ͨΘ͚Ͱͳͦ͞͏ͳͷͰׂѪ
MVP • View - Modelؒͷࢹɾ௨ͷ͕ؔ෮׆ • ࣌Passive Viewͷ֓೦ͳ͔ͬͨͱࢥΘΕΔ • Application
Model͔ΒModelدΓͷཁૉ͕ෆཁʹ • → Application Model͔ΒObserverύλʔϯͷద༻͕ͳ͘ͳΓPresenter ͱมԽ • PresenterɺViewϩδοΫͱঢ়ଶཧʹઐ೦Ͱ͖ΔΑ͏ʹͳΓɺViewͱ ͷ࿈ܞ͕ີʹऔΕΔΑ͏ʹͳͬͨ
MVPͷิ • ControllerͷׂViewʹٵऩ • MVC͕ߟҊ͞Εͨ࣌ɺϢʔβʔೖྗϨϕϧͳσʔλදݱͰ͋ ΓɺController͕ҙຯͷ͋ΔΞΫγϣϯʹม͢Δඞཁ͕͋ͬͨ • iOSͰྫ͑ΔͱɺUIPanGestureRecognizerͷΠϕϯτΛࡹ͘Α͏ͳ ͷʁ •
·ͨɺϨεϙϯμʔνΣʔϯͷࢧԉ͕ͳ͍ঢ়ଶʁ
• ViewͷϩδοΫͱঢ়ଶΛอ࣋͢ΔϞσϧ • Application ModelͱҟͳΓɺViewอ࣋ͨ͠Γߋ৽ͨ͠Γ͠ͳ͍ • Model(υϝΠϯϨΠϠʔ)ͱΓͱΓΛߦ͏ • ViewͷมԽ͠͏Δશঢ়ଶΛอ࣋͠ɺData BindingΛ௨ͯ͡ಉظ͢Δ
• Data Binding۩ମతͳݴٴ͋·Γ͞Ε͍ͯͳ͍ • which I'm hoping will happen some day with technologies like .NET's data binding. Presentation Model
Presentation Model͕͠ಘͨ͜ͱ w 0CTFSWFSύλʔϯʹΑΔ7JFX.PEFMؒͷͭͳ͕ΓΛઈͬͨ w "QQMJDBUJPO.PEFM͔Β0CTFSWFSύλʔϯͷద༻͕ͳ͘ͳΓɺ %BUB#JOEJOHΛ༻͍Δ7JFX.PEFMͱมԽ w "QQMJDBUJPO.PEFMͷஔ͖͕͑ओత
MVVM w 1SFTFOUBUJPO.PEFMΛΑΓ۩ݱԽͨ͠ύλʔϯ w 7JFX.PEFMɺ w 6*ύʔπΛ࠶ར༻͢ΔͨΊͷ7JFXͷநදݱ w %BUB#JOEJOHΛ௨ͯ͡7JFX͔Βར༻͞ΕΔઐ༻ͷ.PEFM ํ
w .PEFMͷσʔλΛ7JFX༻ʹม w 7JFX͕.PEFMͱؒతʹΓͱΓ͢Δ$PNNBOEΛඋ͑Δ
MVVM͕ͨ͠՝ w 81'Λલఏͱ͍ͯ͠ΔͨΊɺ%BUB#JOEJOHʹؔ͢Δݴٴ͕9".-͚ͩͳ Ͳݶఆత w .JDSPTPGUͷதͷਓ͕ߟҊͨ͠ύλʔϯͳͷͰવͱ͍͑વ
MVVMͷิ • Viewͷ։ൃɺσβΠφʔͷͰߦ͏ • UIͷϏδϡΞϧ໘͕ԡ͠ग़͞Ε࢝Ίͨ࣌എܠ͕͔ؔ • ControllerͷׂViewʹٵऩ • MVC͕ߟҊ͞Εͨ࣌ɺϢʔβʔೖྗϨϕϧͳσʔλදݱͰ͋Γɺ Controller͕ҙຯͷ͋ΔΞΫγϣϯʹม͢Δඞཁ͕͋ͬͨ
• iOSͰྫ͑ΔͱɺUIPanGestureRecognizerͷΠϕϯτΛࡹ͘Α͏ͳͷʁ • ·ͨɺϨεϙϯμʔνΣʔϯͷࢧԉ͕ͳ͍ঢ়ଶʁ
·ͱΊ w .7$ʮϓϨθϯςʔγϣϯͱϞσϧͷʯ w "QQMJDBUJPO.PEFMʮ7JFXͷϩδοΫͱঢ়ଶͷஔ͖ॴʯ w 1SFTFOUBUJPO.PEFMʮ%BUB#JOEJOHͷख๏ʯ w .77.ʮ1SFTFOUBUJPO.PEFMΛൃలɺύλʔϯԽʯ w
ʮ7JFXͷϩδοΫͱঢ়ଶͷஔ͖ॴʯΛΊ͙Δྺ࢙ w ಉظํ๏ͱͯ͠%BUB#JOEJOHΛݟग़ͨ͠