코틀린 어떻게 적용할까?

7589a5a8fec022e8af4e46525150a291?s=47 TaeHwan
September 23, 2017

코틀린 어떻게 적용할까?

Android TipTipTip

7589a5a8fec022e8af4e46525150a291?s=128

TaeHwan

September 23, 2017
Tweet

Transcript

  1. ௏ౣܽ যڌѱ ੸ਊೡө? ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 1

  2. ࣗѐ — ӂకജ — RGPKorea ਃӝਃ উ٘۽੉٘ ѐߊ ੗ —

    GDG Seoul Organizer — ਬؘ޷ : ௏ౣܽ द੘ೞӝ — ࠶۽Ӓ : Է ݆਷ ѐߊ੗о غ੗ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 2
  3. ௏ౣܽ੉ۆ? ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 3

  4. ௏ౣܽ੉ۆ? — 2011֙ ୊਺ ࣗѐ — ઇ࠳ۨੋীࢲ ઁ੘ — 2016֙

    1.0 ߓನ ੉റ 1.1.50 ߡ੹ө ૑ ߓನ — উ٘۽੉٘ ҕध ঱য(Java/Kotlin) ૑੿ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 4
  5. ੸೤ࢿ — JDK 6/7/8/9 ૑ਗਵ۽ Java৬ ֫਷ ഐജࢿ — JDK

    6/7ਸ ా೧ Android ҳ ߡ੹ਸ ழߡ — উ٘۽੉٘ झౚ٣য়ܳ ాೠ ৮߷ೠ ో݂җ ࠽٘ दझమ ઁҕ — ೐۽о٘ ੸ਊ оמ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 5
  6. ࢿמ — Java৬ ਬࢎೠ ഋక੄ bytecode ҳઑ۽ ੋ೧ ࡅܰѱ জ੉

    ز੘ — extension function/safety null/Lambda ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 6
  7. Learning Curve — ੉޷ Java ѐߊ੗ۄݶ ־ҳա ੸ਊ оמ —

    ੗ز ஶߡ౴ਸ ాೠ ௏ౣܽ ੊൨੉ оמ — Javaܳ ݽܰݶ ੊൤؊ۄب ࢎਊೞӝ औ૑ח ঋ਺ — ҡଳ਷ Best Practices ࠗ੤ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 7
  8. Kotlin ೟णೞӝ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 8

  9. ޙࢲܳ ࠄ׮ — ޙࢲ݅ఀ જ਷ Ѥ হযਃ ௏ౣܽ যڌѱ ੸ਊೡө?

    thdev.tech, 2017 9
  10. ଼ਸ ࠄ׮ — ৔ޙࢲ੸ٜ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 10

  11. ೠӖ ੗ܐܳ ࠄ׮ — ߣ৉ࢲ, ழפש੄ ଼, ҍ աৢ ௏ౣܽ

    ࢲ੸ٜ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 11
  12. ਬؘ޷ ъ੄ܳ ࠄ׮ — $15 ௢ಪ : ҍ সؘ੉౟(9ਘ ݈

    or 10ਘ ୡ ৘੿) ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 12
  13. kotlin ೐۽ં౟ द੘ೞӝ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 13

  14. Try kotlinਵ۽ द੘ೞӝ — kotlin ࢎ੉౟ীࢲ ઁҕೞח try.kotlinlang.org ௏ౣܽ যڌѱ

    ੸ਊೡө? thdev.tech, 2017 14
  15. ࢜۽਍ ೐۽ં౟৬ ೣԋ द੘ — AS 3.0ীࢲ kotlin ೐۽ં౟۽ द੘ೠ׮

    ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 15
  16. Java ೐۽ં౟ ੹ജೞӝ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 16

  17. Java ೐۽ં౟ ੹ജೞӝ — UIࠗఠ ೡө? — data classࠗఠ ೡө?

    — ࢜۽਍ ಕ੉૑ܳ ୶оೞݶࢲ ૓೯ೡө? — ܻಂష݂ ೞݶࢲ ೡө? ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 17
  18. ੷ח ੉ۧѱ ೮যਃ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 18

  19. ੷ח ੉ۧѱ ೮যਃ — ࢠ೒ ೐۽ં౟ ઁ੘ — kotlin ҙ۲

    ࠶۽Ӓ ੘ࢿ — ਬؘ޷ ъ੄ ઁ੘ — ഥࢎীࢲ पઁ ੸ਊ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 19
  20. ੷ח ੉ۧѱ ೮যਃ - ഥࢎীࢲ ੸ਊೞӝ — ࢜۽ ੸ਊೞח Activity/Fragment

    ӝળਵ۽ ੸ਊ — ੌױ ੗߄۽ ੘ࢿ೧ਃ — command + option + shift + k۽ ੹ജ — ৮߷൤ ߸ജೞ૑ ঋਵפ ੌࠗ ௏٘ܳ ࣚࠇפ׮ — android extensionب ೣԋ ੸ਊ೤פ׮.(UI ࢎਊ੄ ಞ੄ࢿ) — ޙࢲب ࠁҊ, ࢠ೒ب ٜ݅Ҋ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 20
  21. ੷ח ੉ۧѱ ೮যਃ - ഥࢎীࢲ ੸ਊೞӝ — ಕয ೐۽Ӓې߁ਸ ా೧

    ੸ਊ೮যਃ — MVVMਸ ೣԋ ੸ਊ — ఃࠁ٘ח 2ѐܳ ֬Ҋ — ৖ীࢲ ੑ௏٬җ ࢲ۽ ঌ۰઱ݶࢲ ૓೯ — ೠ ׳ р ૓೯ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 21
  22. ੸ਊೞݶࢲ ઱੄ೡ ੼ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 22

  23. null ୊ܻী ઱੄ೞࣁਃ // class name String.kt fun merge(a: String,

    b: String) = "$a $b" ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 23
  24. null ୊ܻী ઱੄ೞࣁਃ - javaীࢲ ࠗܳ ٸ // class name

    String.kt fun merge(a: String, b: String) = "$a $b" public class Sample { @Test public void sample() { System.out.println("merge " + StringKt.merge("A", "B")); } } ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 24
  25. null ୊ܻী ઱੄ೞࣁਃ - javaীࢲ ࠗܳ ٸ // class name

    String.kt fun merge(a: String, b: String) = "$a $b" public class Sample { private String a = "A"; private String b = "B"; @Before public void setUp() { a = null; } @Test public void sample() { System.out.println("merge " + StringKt.merge(a, b)); } } ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 25
  26. null ୊ܻী ઱੄ೞࣁਃ - javaীࢲ ࠗܳ ٸ // class name

    String.kt fun merge(a: String, b: String) = "$a $b" public class Sample { private String a = "A"; private String b = "B"; @Before public void setUp() { a = null; } @Test public void sample() { System.out.println("merge " + StringKt.merge(a, b)); // java.lang.IllegalArgumentException: // Parameter specified as non-null is null: // method tech.thdev.myapplication.StringKt.merge } } ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 26
  27. উ੹ೞѱ ୊ܻೞӝ ਤ೧ࢲ — nullable ୊ܻ — ? ೞաݶ ୊ܻ

    оמ // class name String.kt fun merge(a: String?, b: String?) = "$a $b" ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 27
  28. elvis operator String merge(String a, String b) { return (a

    != null ? a : "a") + " " + (b != null ? b : "b"); } a != null ? a : "a" ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 28
  29. elvis operator -> java String merge(String a, String b) {

    return (a != null ? a : "a") + " " + (b != null ? b : "b"); } a != null ? a : "a" -> kotlin fun merge(a: String?, b: String?) = "${a ?: "a"} ${b ?: "b"}" a ?: "a" ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 29
  30. ਬਊೠ ޙߨٜ — let : null ୓௼ী ઱۽ ࢎਊೞחؘ value(data)ীࢲ݅

    ೞח ѱ જ ইਃ — apply : ࢤࢿҗ زदী ੸ਊೡ ٸ ਬਊ೧ਃ — run : ੉޷ ࢤࢿೠ View ژח ё୓ী ੽Ӕೡ ٸ ਬਊ೧ਃ — with() : Viewী ࢎਊೡ ٸ? — also : ё୓ copy — takeIf : if ੉ݶ return or null — takeUnless : ifо ইפݶ return or null ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 30
  31. ೣࣻ ഛ੢ fun View.onBindView() { tv_title.text = "TITLE" // ...

    } ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 31
  32. Higher-Order Functions class Sample { fun test() { higherOrder {

    (a, b) -> a + b } } fun higherOrder(sum: (Int, Int) -> Int) = sum(10, 20) } ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 32
  33. data class public final class UserInfo { private String name;

    private int age; public UserInfo(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String toString() { return "UserInfo(name=" + this.name + ", age=" + this.age + ")"; } public int hashCode() { return (this.name != null?this.name.hashCode():0) * 31 + this.age; } public boolean equals(Object var1) { if (obj == this) return true; if (!(obj instanceof UserInfo)) { return false; } UserInfo userInfo = (UserInfo) obj; return userInfo.name.equals(name) && userInfo.age == age; } } ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 33
  34. data class — ցޖ ӡয — ࠁউਸ ਤೠ hashCode, equalsח

    ੓যঠ ೣ — get/setب ೙ਃೣ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 34
  35. data class — ցޖ ӡয — ࠁউਸ ਤೠ hashCode, equalsח

    ੓যঠ ೣ — get/setب ೙ਃೣ -> kotlin data class ੸ਊਵ۽ ೠߑী ೧Ѿ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 35
  36. data class data class UserInfo(var name: String?, var age: Int?)

    ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 36
  37. Ӓېࢲ? — ௏ౣܽ જইਃ. — ੷ח ੉ ੿ب۽ ࢎਊ೮যਃ wakatime

    ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 37
  38. Ӓېࢲ? — ഥࢎীࢲ ੸ਊೞݶࢲ ҕࠗೞח ѱ о੢ જҊ — kotlin

    ੸ਊ റ javaо ҾӘೞݶ ٣ஹ౵ੌ ೞӝ — ੌױ java୊ۢ ੘ࢿೞݶࢲ ҕࠗೞࣁਃ. ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 38