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
930
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
0
210
Kafka on Kubernetes with Strimzi
kenju
0
150
AWS DynamoDB Accelerator (DAX) 101
kenju
2
7.1k
Moden browser introduction
kenju
1
400
Cookpad summer internship 2019 - API
kenju
0
10k
Introduction to Design Patterns
kenju
0
81
GraphQL Asia 2019 "Re-architecture of a decade-old app with BFF/GraphQL"
kenju
0
8.9k
Introduction to TypeScript
kenju
0
720
Introduction to Programmatic Ad
kenju
0
260
Other Decks in Programming
See All in Programming
KotlinConf 2025 現地で感じたServer-Side Kotlin
n_takehata
1
230
Rubyでやりたい駆動開発 / Ruby driven development
chobishiba
1
410
データの民主化を支える、透明性のあるデータ利活用への挑戦 2025-06-25 Database Engineering Meetup#7
y_ken
0
320
イベントストーミング図からコードへの変換手順 / Procedure for Converting Event Storming Diagrams to Code
nrslib
1
400
プロダクト志向ってなんなんだろうね
righttouch
PRO
0
160
FormFlow - Build Stunning Multistep Forms
yceruto
1
190
明示と暗黙 ー PHPとGoの インターフェイスの違いを知る
shimabox
2
320
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
110
AIプログラマーDevinは PHPerの夢を見るか?
shinyasaita
1
120
iOSアプリ開発で 関数型プログラミングを実現する The Composable Architectureの紹介
yimajo
2
210
なぜ「共通化」を考え、失敗を繰り返すのか
rinchoku
1
510
ニーリーにおけるプロダクトエンジニア
nealle
0
490
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Done Done
chrislema
184
16k
The World Runs on Bad Software
bkeepers
PRO
69
11k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Writing Fast Ruby
sferik
628
61k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.3k
The Invisible Side of Design
smashingmag
299
51k
Making Projects Easy
brettharned
116
6.3k
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! *
*/