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
That Fresh Mobile Smell
Search
Fred Medlin
February 20, 2014
Programming
1
61
That Fresh Mobile Smell
Android Presenter First talk at TriDroid West.
Fred Medlin
February 20, 2014
Tweet
Share
Other Decks in Programming
See All in Programming
#kanrk08 / 公開版 PicoRubyとマイコンでの自作トレーニング計測装置を用いたワークアウトの理想と現実
bash0c7
1
770
Modern Angular with Signals and Signal Store:New Rules for Your Architecture @enterJS Advanced Angular Day 2025
manfredsteyer
PRO
0
220
Code as Context 〜 1にコードで 2にリンタ 34がなくて 5にルール? 〜
yodakeisuke
0
130
「テストは愚直&&網羅的に書くほどよい」という誤解 / Test Smarter, Not Harder
munetoshi
0
170
システム成長を止めない!本番無停止テーブル移行の全貌
sakawe_ee
1
200
データの民主化を支える、透明性のあるデータ利活用への挑戦 2025-06-25 Database Engineering Meetup#7
y_ken
0
360
Startups on Rails in Past, Present and Future–Irina Nazarova, RailsConf 2025
irinanazarova
0
110
Is Xcode slowly dying out in 2025?
uetyo
1
270
新メンバーも今日から大活躍!SREが支えるスケールし続ける組織のオンボーディング
honmarkhunt
5
7.4k
20250704_教育事業におけるアジャイルなデータ基盤構築
hanon52_
5
790
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
260
5つのアンチパターンから学ぶLT設計
narihara
1
170
Featured
See All Featured
Raft: Consensus for Rubyists
vanstee
140
7k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
6
300
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Fireside Chat
paigeccino
37
3.5k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Rails Girls Zürich Keynote
gr2m
95
14k
BBQ
matthewcrist
89
9.7k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
50
5.5k
It's Worth the Effort
3n
185
28k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Transcript
That Fresh Mobile Smell ! TriDroidWest 2.20.2014 Fred Medlin
None
None
None
NOT BUGS SYMPTOM OF A DEEPER PROBLEM WEAKNESS THAT SLOWS
DOWN DEVELOPMENT CODE SMELLS
976 LINES KNOWS TOO MUCH DOES TOO MUCH LARGE CLASS
=> GOD OBJECT
BUSINESS DATA AND LOGIC MODEL USER STORY BEHAVIOR USER INTERACTIONS
PRESENTER VIEW PRESENTER FIRST
BUSINESS DATA AND LOGIC MODEL USER STORY BEHAVIOR USER INTERACTIONS
PRESENTER VIEW PRESENTER FIRST
BUSINESS DATA AND LOGIC MODEL USER STORY BEHAVIOR USER INTERACTIONS
PRESENTER VIEW PRESENTER FIRST
HOW IT’S DONE 1.Start with a user story 2.Stub a
presenter 3.Write interface methods for model and view 4.Add presenter tests to confirm the methods were called
1. USER STORY Using my current latitude and longitude, find
and display the nearest geo-tagged wikipedia entry.
2. STUB PRESENTER public class GeoWikiPresenter {! private GeoWikiModel model;!
private GeoWikiView view;! ! public GeoWikiPresenter(GeoWikiModel model, GeoWikiView view) {! this.model = model;! this.view = view;! }! }!
3. MODEL/VIEW INTERFACE METHODS public interface GeoWIkiModel {! !void findLocation();!
!void queryArticles(float latitude, float longitude);! }! ! public interface GeoWikiView {! !void showProgress();! !void hideProgress();! !void displayPage(String url);! }!
4. PRESENTER TESTS public class GeoWikiPresenterTest {! !@Mock GeoWikiModel model;!
!@Mock GeoWikiView view;! !GeoWikiPresenter presenter;! ! !@Before! !public void setup() {! !!Mockito.initAnnotations(this);! !!presenter = new GeoWikiPresenter(model, view);! !}! }!
4. PRESENTER TESTS (2) @Test! ! public void searchesForLocation() {!
! ! verify(model).findLocation();! ! ! verify(view).showProgress();! ! }! ! ! @Test! ! public void queryWikiLocation() {! ! ! presenter.onLocationFound(new FoundLocationEvent(lat, lon));! ! ! verify(model).queryArticles(lat, lon);! ! }!
4. PRESENTER TESTS (3) public class GeoWikiPresenter {! private GeoWikiModel
model;! private GeoWikiView view;! ! public GeoWikiPresenter(GeoWikiModel model, GeoWikiView view) {! this.model = model;! this.view = view;! model.findLocation();! view.showProgress();! ! @Subscribe! public void onLocationFound(FoundLocationEvent event) {! ! model.queryArticles(event.getLatitude(), event.getLongitude());! }! ! @Subscribe! public void onArticleFound(FoundArticleEvent event) {! ! view.hideProgress();! ! view.displayPage(event.getUrl());! }! }! }!
None
3. MODEL/VIEW INTERFACE METHODS public interface GeoWIkiModel {! !void findLocation();!
!void queryArticles(float latitude, float longitude);! }! ! public interface GeoWikiView {! !void showProgress();! !void hideProgress();! !void displayPage(String url);! }!
FRESH public class MainActivity extends Activity {! ! ! GeoWikiPresenter
presenter;! ! ! @Override! ! public void onCreate(Bundle savedInstanceState) {! ! ! super.onCreate(savedInstanceState);! ! ! setContentView(R.layout.activity_main);! ! ! presenter = new GeoWikiPresenter(new GeoWikiModelImpl(), new GeoWikiViewImpl());! ! }! ! ! @Override! ! public void onPause() {! ! ! super.onPause();! ! ! BusProvider.unregister(presenter);! ! }! ! ! @Override! ! public void onResume() {! ! ! super.onPause();! ! ! BusProvider.register(presenter);! ! }! }!
• Traditional SW mistake • Focuses on invisible things MODEL
FIRST • Seems reasonable, but… • Views attract strong feeling • High rate of changes • Hard to test VIEW FIRST ALTERNATIVES?
None
Fred Medlin
[email protected]
@fmedlin
LINKS Mockito - https://code.google.com/p/mockito/ Otto - http://square.github.io/otto/
All photos via Creative Commons Licenses from flickr.com ! -
Attribution-NonCommercial-NoDerivs 2.0 Generic (CC BY-NC-ND 2.0) - (mbshane) http://www.flickr.com/photos/mbshane/3165456548/ - (reid-bee) http://www.flickr.com/photos/reid-bee/5521024764/ - (captain_chickenpants) http://www.flickr.com/photos/captain_chickenpants/320441513/ - (RosenRakuen) http://www.flickr.com/photos/91134569@N05/8365293556/ ! Attribution-NonCommercial-ShareAlike 2.0 Generic (CC BY-NC-SA 2.0) - (clintjcl) http://www.flickr.com/photos/clintjcl/2708117471/ ! Attribution 2.0 Generic (CC BY 2.0) - (jeffreyww) http://www.flickr.com/photos/jeffreyww/4867984686/ - (quietlyurban.com) http://www.flickr.com/photos/83118222@N06/9689975423/ ! Attribution-NonCommercial 2.0 Generic (CC BY-NC 2.0) - (hatalmas) http://www.flickr.com/photos/hatalmas/6094281702/ PHOTO CREDITS