Upgrade to Pro — share decks privately, control downloads, hide ads and more …

코틀린 어떻게 적용할까?

TaeHwan
September 23, 2017

코틀린 어떻게 적용할까?

Android TipTipTip

TaeHwan

September 23, 2017
Tweet

More Decks by TaeHwan

Other Decks in Programming

Transcript

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

    GDG Seoul Organizer — ਬؘ޷ : ௏ౣܽ द੘ೞӝ — ࠶۽Ӓ : Է ݆਷ ѐߊ੗о غ੗ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 2
  2. ௏ౣܽ੉ۆ? — 2011֙ ୊਺ ࣗѐ — ઇ࠳ۨੋীࢲ ઁ੘ — 2016֙

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

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

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

    ੗ز ஶߡ౴ਸ ాೠ ௏ౣܽ ੊൨੉ оמ — Javaܳ ݽܰݶ ੊൤؊ۄب ࢎਊೞӝ औ૑ח ঋ਺ — ҡଳ਷ Best Practices ࠗ੤ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 7
  6. ೠӖ ੗ܐܳ ࠄ׮ — ߣ৉ࢲ, ழפש੄ ଼, ҍ աৢ ௏ౣܽ

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

    or 10ਘ ୡ ৘੿) ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 12
  8. Java ೐۽ં౟ ੹ജೞӝ — UIࠗఠ ೡө? — data classࠗఠ ೡө?

    — ࢜۽਍ ಕ੉૑ܳ ୶оೞݶࢲ ૓೯ೡө? — ܻಂష݂ ೞݶࢲ ೡө? ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 17
  9. ੷ח ੉ۧѱ ೮যਃ — ࢠ೒ ೐۽ં౟ ઁ੘ — kotlin ҙ۲

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

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

    ੸ਊ೮যਃ — MVVMਸ ೣԋ ੸ਊ — ఃࠁ٘ח 2ѐܳ ֬Ҋ — ৖ীࢲ ੑ௏٬җ ࢲ۽ ঌ۰઱ݶࢲ ૓೯ — ೠ ׳ р ૓೯ ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 21
  12. null ୊ܻী ઱੄ೞࣁਃ // class name String.kt fun merge(a: String,

    b: String) = "$a $b" ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 23
  13. 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
  14. 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
  15. 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
  16. উ੹ೞѱ ୊ܻೞӝ ਤ೧ࢲ — nullable ୊ܻ — ? ೞաݶ ୊ܻ

    оמ // class name String.kt fun merge(a: String?, b: String?) = "$a $b" ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 27
  17. 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
  18. 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
  19. ਬਊೠ ޙߨٜ — 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
  20. ೣࣻ ഛ੢ fun View.onBindView() { tv_title.text = "TITLE" // ...

    } ௏ౣܽ যڌѱ ੸ਊೡө? thdev.tech, 2017 31
  21. 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
  22. 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
  23. data class — ցޖ ӡয — ࠁউਸ ਤೠ hashCode, equalsח

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

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

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

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