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
33
MVVM
Takuma Shimizu
June 24, 2023
Tweet
Share
More Decks by Takuma Shimizu
See All by Takuma Shimizu
Swift Attributes
hokuron
0
340
Peek in Calendar implementation of swift-foundation
hokuron
0
140
Summon Rust from Swift
hokuron
0
600
Opaque Result Type in Swift with Rust
hokuron
0
130
Generalized accessors
hokuron
0
58
Ownership of Swift as seen from iteration and Rust
hokuron
1
610
Clean Architecture 3
hokuron
0
24
Clean Architecture 2
hokuron
0
46
Create MLで犬と猫の肉球を学習
hokuron
0
80
Other Decks in Programming
See All in Programming
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.1k
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
4
640
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
役立つログに取り組もう
irof
28
9.6k
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
600
CSC509 Lecture 11
javiergs
PRO
0
180
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
330
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
Ethereum_.pdf
nekomatu
0
460
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
BBQ
matthewcrist
85
9.3k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
The Invisible Side of Design
smashingmag
298
50k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
It's Worth the Effort
3n
183
27k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.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Λݟग़ͨ͠