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
MVP on Android: why do you need it?
Search
Stan Kocken
May 02, 2016
Programming
200
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
MVP on Android: why do you need it?
Stan Kocken
May 02, 2016
More Decks by Stan Kocken
See All by Stan Kocken
Remote Control your App
stankocken
3
500
Unit Test your code, even your UI
stankocken
1
320
EfficientAdapter
stankocken
1
120
Other Decks in Programming
See All in Programming
ALB ログから Trace を気合で繋げる技術
fohte
7
840
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
110
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
120
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
600
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
130
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
120
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
Go 1.27 における memory allocation の高速化
andpad
0
370
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
3
460
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
230
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.3k
週末にAI-DLCを本気で回したら$1,600溶けた
hbashimizu
0
120
Featured
See All Featured
Designing for Timeless Needs
cassininazir
1
460
A Modern Web Designer's Workflow
chriscoyier
698
190k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Accessibility Awareness
sabderemane
1
190
sira's awesome portfolio website redesign presentation
elsirapls
0
380
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
Tell your own story through comics
letsgokoyo
1
1.1k
A Soul's Torment
seathinner
7
3.5k
Agile that works and the tools we love
rasmusluckow
331
22k
Transcript
MVP: why do you need it? @stan_kocken
Join our team! dashlane.com/jobs Never forget another password Editor Choice
Top Developer 4.5/5 - 1M+ downloads
MVP: why do you need it?
Activity
BaseActivity: 1600+ lines A base activity that handles common functionality
in the app. This includes the navigation drawer, login and authentication, Action Bar tweaks, amongst others.
God Object
Activity
Activity/Fragments Usually contain: - actions on View - handle clicks
- read/write in database / SharePreference - network calls - …
Activity/Fragments Very hard to: - read - test - refactor
- reuse code - …
Separation of Concerns
Architecture MVP Model View Presenter state-change events updates view update
model user events
Architecture MVP: in Android, my way Model View Presenter
Architecture MVP: in Android, my way Model: access data store
state View Presenter
Architecture MVP: in Android, my way Model: access data store
state View Presenter: present data to UI
Architecture MVP: in Android, my way Model: access data store
state View: touch Android View no business logic Presenter: present data to UI
Architecture MVP: in Android, my way View: touch Android View
no business logic Presenter: present data to UI Model: DataProvider access data store state
Architecture MVP: in Android, my way Model: DataProvider access data
store state View: ViewProxy touch Android View no business logic Presenter: present data to UI
Presenter DataProvider ViewProxy Activity View Strong Reference Weak Reference Other
“Strong” Reference on DataProvider, Presenter or ViewProxy forbidden. Use WeakReference. Architecture MVP: in Android, my way
Example
DataProvider Presenter ViewProxy Creation refreshBoard() getGameBoard() setBoxValue( int x, int
y, int boxType);
DataProvider Presenter ViewProxy User click box onSelectBox(int x, int y)
play(int x, int y) refreshBoard() …
Definition public interface BoardDef { interface IPresenter extends BaseDef.IPresenter
{ void refreshBoard(); void onSelectBox(int x, int y); } interface IDataProvider extends BaseDef.IDataProvider { GameBoard getGameBoard(); void play(int x, int y); } interface IView extends BaseDef.IView { void setBoxValue(int x, int y, int boxType); } }
Test the UI Android stuffs TextView ImageView … View Proxy
Already Tested by framework team
Test the UI View Proxy Mock Mock Mock
@stan_kocken Presentation pattern: github.com/StanKocken/Presentation TicTacToe Example: github.com/StanKocken/TicTacToe