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
610
Opaque Result Type in Swift with Rust
hokuron
0
130
Generalized accessors
hokuron
0
62
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
84
Other Decks in Programming
See All in Programming
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
450
命名をリントする
chiroruxx
1
380
今からはじめるAndroidアプリ開発 2024 / DevFest 2024
star_zero
0
1k
CSC305 Lecture 26
javiergs
PRO
0
140
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
300
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
130
ドメインイベント増えすぎ問題
h0r15h0
1
120
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
260
モバイルアプリにおける自動テストの導入戦略
ostk0069
0
110
暇に任せてProxmoxコンソール 作ってみました
karugamo
1
720
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
510
110k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Visualization
eitanlees
146
15k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Facilitating Awesome Meetings
lara
50
6.1k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
49k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
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Λݟग़ͨ͠