Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Android Architectures and Clean Code
Search
Frankie Sardo
November 24, 2013
Technology
820
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Android Architectures and Clean Code
Frankie Sardo
November 24, 2013
Other Decks in Technology
See All in Technology
初海外で注意すべきこと12選!!!安全快適なre:invent生活にするために
yuuuuuuu168
1
160
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
100
ストレスなくAIと付き合いたい!こんなときどうしてる?
namiki64
3
510
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
180
re:Invent初参加で変わったこと、2回目にやってみたいこと(JAWS-UG彩の国埼玉 #12)
mhrtech
2
220
アウトプット初心者、半年間のふりかえり
4o1sobblue
0
430
Webの常識が通じないHTMLメールのダークモード
teamlab
PRO
0
120
PagerDuty Tech Hub-鳴らすけれど、人は動かない
ezaki
0
170
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
330
AIにシークレットを見せない、WSL2で安全な開発環境
yazm
0
300
夫婦で子育てするための育児標準化
codmoninc
PRO
0
340
V8のArray.prototype.flatを最大約20倍速くするまでと、巨大OSSへの大規模コミットの道のり
riyaamemiya
0
290
Featured
See All Featured
Exploring anti-patterns in Rails
aemeredith
4
540
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
It's Worth the Effort
3n
188
29k
ラッコキーワード サービス紹介資料
rakko
1
5.3M
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
Building an army of robots
kneath
307
47k
Navigating Team Friction
lara
192
16k
The Language of Interfaces
destraynor
162
27k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
730
Color Theory Basics | Prateek | Gurzu
gurzu
1
490
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Transcript
Android Architectures and Clean Code
None
None
None
None
None
None
Slide google maps tablet search result
None
// manager made me do it // hack for release
1.2.4 // this should never happen // TODO: fix me before Sunday // WTF???
None
None
A definition Clean Code min(X) / X = WTF /
LINE_OF_CODE
None
None
None
Object calisthenics - One level of indentation per method -
Don’t use the ELSE keyword - Wrap all primitives and String - First class collections - One dot per line - Don’t abbreviate - Keep all entities small - No classes with more than two instance variables - No getters and setters
None
Correctness by design Order[] ordersWithinRange(String startDate, String endDate) {...}
Correctness by design Order[] ordersWithinRange(Calendar startDate, Calendar endDate) {...}
Correctness by design Order[] ordersWithinRange(DateRange range) {...}
Kill the boilerplate code Intent intent = new Intent(this, VideoActivity.class);
intent.putExtra("video", mVideo); intent.setFlags(FLAG_ACTIVITY_SINGLE_TOP); this.startActivity(intent);
Kill the boilerplate code navigate(this) .clearingBackStack() .toVideoActivity() .withVideo(mVideo);
Bonus project: Icepick @Icicle String username; public void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState); Bundles.restoreInstanceState(this, savedInstanceState); } public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); Bundles.saveInstanceState(this, outState); }
Mutability class Event { @JsonName("o_name") void setName(String name) {...} @JsonName("D_address")
void setAddress(String date) {...} @JsonName("valid_for") void setExpires(String duration) {...} }
Mutability class Event { final String name; final Address address;
final DateRange duration; Event(String name, Address address, DateRange duration) {...} static class Address {...} static class DateRange {...} }
Mutability String doSomething() { StringBuffer buffer = new StringBuffer(); if
(buffer.size() == 0) { buffer.append("("); } // Share a mutable instance. // Potential bugs will lurk here. return doSomethingElse(buffer); }
Mutability String doSomething() { String partialResult = ""; if (partialResult.length()
== 0) { partialResult += "("; } // String is immutable. // Sharing won't cause troubles to the caller. return doSomethingElse(partialResult); }
Bonus project: clj-ds - Persistent Stack - Persistent Vector -
Persistent Set - Persistent Map - … and many more!
None
None
A definition (cont.) Clean Architecture min(Y) / Y = WTF
/ DATA_FLOW
None
None
None
None
The way Content Provider: - Loaders - Cursors - Database
- SyncAdapter
None
The way Dagger: - Modules - In-memory singletons - Event
bus - Mortar/Flow
None
The way RxJava: - Composition - Observable state - Subscriptions
None
None
Information flow
Sync flow On New day: fetch products and offers On
App opening: sync basket, user data, orders On Delivery screen: sync available slots On Basket changed: sync basket
The lean way Remix: - SyncAdapter + BG ThreadPoolExecutor -
Loaders for each piece of info - In-memory mutable data - RxJava for composition (Basket + Products) - Separate syncing from displaying
None
None
Questions? @frankiesardo +Frankie Sardo frankiesardo