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
Startups on Rails in Past, Present and Future–Irina Nazarova, RailsConf 2025
irinanazarova
0
110
PostgreSQLのRow Level SecurityをPHPのORMで扱う Eloquent vs Doctrine #phpcon #track2
77web
2
530
LT 2025-06-30: プロダクトエンジニアの役割
yamamotok
0
760
Deep Dive into ~/.claude/projects
hiragram
14
2.6k
「テストは愚直&&網羅的に書くほどよい」という誤解 / Test Smarter, Not Harder
munetoshi
0
170
20250628_非エンジニアがバイブコーディングしてみた
ponponmikankan
0
680
ペアプロ × 生成AI 現場での実践と課題について / generative-ai-in-pair-programming
codmoninc
1
18k
Rails Frontend Evolution: It Was a Setup All Along
skryukov
0
140
Team operations that are not burdened by SRE
kazatohiei
1
310
XP, Testing and ninja testing
m_seki
3
250
Hack Claude Code with Claude Code
choplin
4
2.1k
脱Riverpod?fqueryで考える、TanStack Queryライクなアーキテクチャの可能性
ostk0069
0
150
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Bash Introduction
62gerente
613
210k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
6
300
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.4k
Making Projects Easy
brettharned
116
6.3k
Writing Fast Ruby
sferik
628
62k
GraphQLとの向き合い方2022年版
quramy
49
14k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
The Cost Of JavaScript in 2023
addyosmani
51
8.5k
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