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
Don't Reinvent The Wheel ~ For All Android Begi...
Search
Ken Wagatsuma
November 23, 2015
Programming
0
900
Don't Reinvent The Wheel ~ For All Android Beginners ~
Advice for all Android Development Beginners how to learn themself.
Ken Wagatsuma
November 23, 2015
Tweet
Share
More Decks by Ken Wagatsuma
See All by Ken Wagatsuma
Pregel Graph Compute Engines - Supersteps Exampls
kenju
1
200
Kafka on Kubernetes with Strimzi
kenju
1
140
AWS DynamoDB Accelerator (DAX) 101
kenju
3
6.9k
Moden browser introduction
kenju
1
370
Cookpad summer internship 2019 - API
kenju
0
10k
Introduction to Design Patterns
kenju
0
69
GraphQL Asia 2019 "Re-architecture of a decade-old app with BFF/GraphQL"
kenju
0
8.8k
Introduction to TypeScript
kenju
0
690
Introduction to Programmatic Ad
kenju
0
230
Other Decks in Programming
See All in Programming
asdf-ecspresso作って 友達が増えた話 / Fujiwara Tech Conference 2025
koluku
0
1.3k
Findy Team+ Awardを受賞したかった!ベストプラクティス応募内容をふりかえり、開発生産性向上もふりかえる / Findy Team Plus Award BestPractice and DPE Retrospective 2024
honyanya
0
140
PHPカンファレンス 2024|共創を加速するための若手の技術挑戦
weddingpark
0
130
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
290
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
630
Rubyでつくるパケットキャプチャツール
ydah
0
160
VisionProで部屋の明るさを反映させるシェーダーを作った話
segur
0
100
php-conference-japan-2024
tasuku43
0
430
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
930
Amazon Nova Reelの可能性
hideg
0
190
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
0
110
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
6
1.4k
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
950
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Side Projects
sachag
452
42k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Music & Morning Musume
bryan
46
6.3k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
327
24k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.5k
What's in a price? How to price your products and services
michaelherold
244
12k
Thoughts on Productivity
jonyablonski
68
4.4k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.8k
Transcript
Don’t Reinvent The Wheel Kenju Wagatsuma
Agenda: -> ❖ 1m : Introduction ❖ 3m : Main
part ❖ 1m : Conclusion
/** * Introduce Myself * * @kenjuwagatsuma */
'me' = { name : 'Kenju Wagatsuma ( KJ )’,
}
'me' = { name : 'Kenju Wagatsuma ( KJ )’,
company : 'Recruit Technologies Co.,LTD.', }
'me' = { name : 'Kenju Wagatsuma ( KJ )’,
company : 'Recruit Technologies Co.,LTD.', profession : 'Android Development', }
'me' = { name : 'Kenju Wagatsuma ( KJ )’,
company : 'Recruit Technologies Co.,LTD.', profession : 'Android Development', favs : { 'Book' : ‘Soft Skills', 'Music' : ‘The Beatles', 'Hobby' : ‘Acoustic Guitar', 'Sport' : 'Rugby' } }
/** * My Story * * @author me */
```java /** * Validate user id input from a form
* * @param String userID */ private void validateUserId(String userId) { // Validate userId } ```
```java private void validateUserId(String userId) { // Check input field
here if (userId == null || userId.length() == 0) { return; } // Validate userId } ```
```java // Utility class public static class UtilClass { public
static boolean checkStringInput(String str) { if (str == null || str.length() == 0) { return true; } else { return false; } } } // Activity class public void MainActivity extends Activity { private void validateUserId(String userId) { if(UtilClass.checkStringInput(userId)) return; // Validate userId // ... } } ```
/** * @codereview * */
None
None
```java private void validateUserId(String userId) { // Check input field
here if (userId == null || userId.length() == 0) { return; } // Validate userId } ```
```java private void validateUserId(String userId) { // Check input field
here if (TextUtils.isEmpty(userId)) { return; } // Validate userId } ```
Okay, I’ll look at the source code, sir…
```java /** * Returns true if the string is null
or 0-length. * @param str the string to be examined * @return true if str is null or zero length */ public static boolean isEmpty(CharSequence str) { if (str == null || str.length() == 0) return true; else return false; } ```
……
……ʮ͍ͬ͠ΐΜ͚wʯ
```java public static boolean checkStringInput(String str) { if (str ==
null || str.length() == 0) { return true; } else { return false; } } ``` My Code
```java public static boolean isEmpty(CharSequence str) { if (str ==
null || str.length() == 0) return true; else return false; } ``` android.TextUtils
```java public static boolean checkStringInput(String str) { if (str ==
null || str.length() == 0) { return true; } else { return false; } } ``` My Code
```java public static boolean isEmpty(CharSequence str) { if (str ==
null || str.length() == 0) return true; else return false; } ``` android.TextUtils
……ʮ͍ͬ͠ΐΜ͚wʯ(࠶)
/** * Why TextUtils? * (not my own code) *
*/
#47 ʮϥΠϒϥϦʔΛΓɺ ϥΠϒϥϦʔΛ͏ʯ “Effective Java” 2nd Edition
#47 ʮϥΠϒϥϦʔΛΓɺϥΠϒϥϦʔΛ͏ʯ ར̍ ❖ ඪ४ϥΠϒϥϦΛ༻͢Δ͜ͱͰɺͦΕΛॻ͍ ͨઐՈͷࣝͱɺͦΕΛ͋ͳͨΑΓલʹ༻ ͨ͠ਓʑͷܦݧΛར༻͢Δ͜ͱʹͳΓ·͢ɻ “Effective Java” 2nd
Edition
#47 ʮϥΠϒϥϦʔΛΓɺϥΠϒϥϦʔΛ͏ʯ ར̎ ❖ ࣗͷ՝ʹগ͔͠Γؔ࿈͍ͯ͠Δʹର ͢ΔͨΓతͳղܾࡦΛॻ͘͜ͱͰɺ࣌ؒΛແ ବʹ͢Δඞཁ͕ແ͍ɻ “Effective Java” 2nd
Edition
#47 ʮϥΠϒϥϦʔΛΓɺϥΠϒϥϦʔΛ͏ʯ ར̏ ❖ ࣗͰԿ͠ͳͯ͘ɺଟ͘ͷਓʹΑͬͯ܁ Γฦ͠ॻ͖͞ΕΔίʔυɺ࣌ؒͱڞʹύ ϑΥʔϚϯε͕վળ͞ΕΔʢࣗͷίʔυͰͦ ͏͍͔ͳ͍ʣɻ “Effective Java”
2nd Edition
/** * So what? * * @return Conclusion */
#47 ʮϥΠϒϥϦʔΛΓɺϥΠϒϥϦʔΛ͏ʯ For All Beginners,
1. Know Android Library 2. Use Library methods 3. See
& Understand source codes 3 Steps for Learning,
/** * Appendix * */
❖ android.text.format.DateUtils ❖ android.text.format.Formatter ❖ android.text.TextUtils ❖ android.text.util.Linkify ❖ android.util.Pair<F,
S> ❖ android.util.SparseArray<E> ❖ android.util.Log ❖ android.util.LruCache ❖ android.graphics.Color ❖ android.media.ThumbnailUtils android.*
android.text.TextUtils ```java /** * ༩͑ΒΕͨจࣈྻ͕͔ͯ͢Ͳ͏͔Λఆ */ public static boolean isDigitsOnly(CharSequence
str) { final int len = str.length(); for (int i = 0; i< len; i++) { if (!Character.isDigit(str.charAt(i)) { return false; } } return true; } ```
android.text.TextUtils ```java /** * HTMLΤϯίʔυ */ public static boolean htmlEncode(String
s) { StringBuilder sb = new StringBuilder(); char c; for (int i = 0; i < s.length(); i++) { c = s.charAt(i); switch(c) { case '<': sb.append("<"); break; //...ͦͷଞͷΤϯίʔυ͖͢จࣈ default: sb.append(c); } } return sb.toString(); }
android.text.TextUtils ```java /** * trim()Ͱআ͞ΕۭͨനͷΛฦ͠·͢ */ public static int getTrimmedLength(CharSequence
s) { int len = s.length(); int start = 0; while (start < len && s.charAt(start) <= ' ') { start++; } int end = 0; while (end > start && s.charAt(end - 1) <= ' ') { end--; } return end - start; } ```
android.database.DatabaseUtils ```java /** * WHERE۟࡞ͷϔϧύʔϝιου */ public static String concatenateWhere(String
a, String b) { if (TextUtils.isEmpty(a)) { return b; } if (TextUtils.isEmpty(b)) { return a; } return "(" + a + ") AND (" + b + ")"; } ```
android.database.DatabaseUtils ```java /** * CursorͷதΛग़ྗ͢Δσόοά༻ϝιου */ public static void dumpCursor(Cursor
cursor) { dumpCursor(cursor, System.out); } public static void dumpCursor(Cursor cursor, PrintStream stream) { stream.println(">>>>> Dumping cursor " + cursor); if (cursor != null) { int startPos = cursor.getPosition(); cursor.moveToPosition(-1); while (cursor.moveToNext()) { dumpCurrentRow(cursor, stream); } cursor.moveToPosition(startPos); } stream.println("<<<<<"); } ```
android.database.DatabaseUtils ```java /** * CursorͷݱࡏͷߦΛग़ྗ͢Δ */ public static void dumpCurrentRow(Cursor
cursor, PrintStream stream) { String[] cols = cursor.getColumnNames(); stream.println("" + cursor.getPosition() + " {"); int length = cols.length; for (int i = 0; i < length; i++) { String value; try { value = cursor.getString(i); } catch (SQLiteException e) { value = "<unprintable>"; } stream.println(" " + cols[i] + '=' + value); } stream.println("}"); } ```
/** * And Much More! * * Happy Coding! *
*/