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
880
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
360
Cookpad summer internship 2019 - API
kenju
0
10k
Introduction to Design Patterns
kenju
0
66
GraphQL Asia 2019 "Re-architecture of a decade-old app with BFF/GraphQL"
kenju
0
8.8k
Introduction to TypeScript
kenju
0
670
Introduction to Programmatic Ad
kenju
0
220
Other Decks in Programming
See All in Programming
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
ヤプリ新卒SREの オンボーディング
masaki12
0
130
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
300
役立つログに取り組もう
irof
28
9.6k
flutterkaigi_2024.pdf
kyoheig3
0
140
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
940
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.2k
Featured
See All Featured
Optimizing for Happiness
mojombo
376
70k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Building Your Own Lightsaber
phodgson
103
6.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
96
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
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! *
*/