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 Beginners ~
Search
Ken Wagatsuma
November 23, 2015
Programming
0
850
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
190
Kafka on Kubernetes with Strimzi
kenju
1
130
AWS DynamoDB Accelerator (DAX) 101
kenju
3
6.7k
Moden browser introduction
kenju
1
350
Cookpad summer internship 2019 - API
kenju
0
10k
Introduction to Design Patterns
kenju
0
60
GraphQL Asia 2019 "Re-architecture of a decade-old app with BFF/GraphQL"
kenju
0
8.7k
Introduction to TypeScript
kenju
0
660
Introduction to Programmatic Ad
kenju
0
200
Other Decks in Programming
See All in Programming
feature環境をGitHub ActionsとCloudFormationでいい感じに管理する
nealle
2
310
Exploring the Gradually Lost Technical Skills in the Cloud Native Era
hwchiu
2
3.9k
MIERUNE BBQにおけるユーザー中心設計()
mierune
PRO
1
110
わかりやすい正解を捨てて、コトに向き合う - スクラムフェス金沢2024 スポンサーセッション
yusukekokubo
0
170
Advanced App Shrinking Techniques
cbeyls
2
150
CSC307 Lecture 14
javiergs
PRO
0
220
Webエディタライブラリ 「CodeMirror」から学ぶ Webアプリ開発のテクニック
ryosukeigarashi
0
250
12年前の『型システム入門』翻訳の思い出話
mame
11
1.2k
Introduction of Happy Eyeballs Version 2 (RFC8305) to the Socket library
coe401_
1
220
Cloudflare Workers x AWS Lambdaの組み合わせユースケース / Cloudflare Workers x AWS Lambda Combination Use Case
seike460
PRO
2
310
実用的かつリーズナブルな 「Azure × Gemini × LINE」~キャラクターBot 実装ライブデモ~
tomodo_ysys
1
170
ピグパーティにおけるMongoDB CommunityバージョンからAtlasへの移行事例
10969hotaka
0
130
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
63
4.2k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
90
47k
The Brand Is Dead. Long Live the Brand.
mthomps
52
36k
Agile that works and the tools we love
rasmusluckow
325
20k
What's new in Ruby 2.0
geeforr
338
31k
A designer walks into a library…
pauljervisheath
201
24k
WebSockets: Embracing the real-time Web
robhawkes
59
7.2k
Happy Clients
brianwarren
94
6.6k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
353
29k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
18
1.2k
Designing with Data
zakiwarfel
96
5k
Principles of Awesome APIs and How to Build Them.
keavy
124
16k
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! *
*/