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
680
Introduction to Programmatic Ad
kenju
0
230
Other Decks in Programming
See All in Programming
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
340
MCP with Cloudflare Workers
yusukebe
2
300
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
230
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
140
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
880
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
400
iOS開発におけるCopilot For XcodeとCode Completion / copilot for xcode
fuyan777
1
1.3k
.NETでOBS Studio操作してみたけど…… / Operating OBS Studio by .NET
skasweb
0
110
Findy Team+ Awardを受賞したかった!ベストプラクティス応募内容をふりかえり、開発生産性向上もふりかえる / Findy Team Plus Award BestPractice and DPE Retrospective 2024
honyanya
0
130
traP の部内 ISUCON とそれを支えるポータル / PISCON Portal
ikura_hamu
0
170
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
6
1.4k
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
370
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
5
200
Unsuck your backbone
ammeep
669
57k
Raft: Consensus for Rubyists
vanstee
137
6.7k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
GitHub's CSS Performance
jonrohan
1030
460k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
A designer walks into a library…
pauljervisheath
205
24k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
How to Ace a Technical Interview
jacobian
276
23k
GraphQLとの向き合い方2022年版
quramy
44
13k
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! *
*/