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

1年ぶりにやりなおすKotlinアプリ開発

 1年ぶりにやりなおすKotlinアプリ開発

0d687d04fd46edcacf30ee4f9b3ede7d?s=128

Kazuya Kitahara

July 12, 2017
Tweet

More Decks by Kazuya Kitahara

Other Decks in Programming

Transcript

  1. 1೥ͿΓʹ΍Γͳ͓͢KotlinΞϓϦ։ൃ .HSBN*OD ๺ݪ࿨໵

  2. ࣗݾ঺հ w ๺ݪ࿨໵ w גࣜձࣾNHSBNʢچגࣜձࣾ-JQʣΤϯδχΞ w ૑ۀϝϯόʔͷ̍ਓͰ͢ɻ w ೥൒લʹϛΫγΟ͔Βస৬͠·ͨ͠ɻ w

    "OESPJEϝΠϯɻ8FCɾJ04ঢ়گʹԠͯ͡։ൃ w झຯ͸өըɾອը
  3. γϯɾΰδϥͷҠಈܦ࿏Λ஍ਤ্ͰΞχϝʔγϣϯ w U (&0(3"1)*$0'(0%;*--" IUUQHFPHPE[JMMBUL

  4. ΤϜάϥϜੑ֨਍அ w ໰ͷ࣭໰Ͱੑ֨Λਖ਼֬਍அ w ΩϟονʔͳΞ΢τϓοτ w ແྉ w ϲ݄Ͱສਓͷํ͕਍அ

  5. 1೥ͿΓʹ΍Γͳ͓͢KotlinΞϓϦ։ൃ

  6. ࿩͢ࣄ w ೥ͿΓʹ,PUMJOΛ৮ͬͯࢥͬͨࣄ w ,PUMJOͱҰॹʹར༻ՄೳͳϥΠϒϥϦ

  7. ೥ͿΓʹ,PUMJOΛ৮ͬͯࢥͬͨࣄ

  8. ࢖͑ΔϥΠϒϥϦ͕૿͑ͯΔ w "OOPUBUJPOϓϩηοαʔΛར༻͍ͯ͠ΔϥΠϒϥϦ͸࢖ ͑ͨΓ࢖͑ͳ͔ͬͨΓ͍ͯͨ͠ w %BHHFS%BUB#JOEJOH΋͏·͘ಈ͔ͳ͔ͬͨΑ͏ʹه Ա w ৭ΜͳϥΠϒϥϦ͕࢖͑ΔΑ͏ʹͳͬͯΔʂ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UF TBWFE*OTUBODF4UBUF#VOEMF \
 TVQFSPO$SFBUF TBWFE*OTUBODF4UBUF 
 4UBUF4BWFSSFTUPSF*OTUBODF4UBUF UIJT

    TBWFE*OTUBODF4UBUF  ^ .BJO"DUJWJUZLU !4UBUF
 WBSOBNF4USJOH OVMM 
  34. ·ͱΊ w ೥ͿΓʹ,PUMJOΛ࢖ͬͯΈͨΒ࢖͑ΔϥΠϒϥϦ͕͢͝ ͘૿͑ͯͯศརͩͬͨ w ,PUMJOͷجຊػೳ͸૬มΘΒͣૉఢ w ͜Ε͔Βͷ։ൃ͸,PUMJOͰ࢝ΊΔͷ͕ྑͦ͞͏ ೥ͿΓʹ࢖ͬͨΒ΍ͬͺΓ,PUMJO͸ྑ͔ͬͨ

  35. גࣜձࣾNHSBN͸ΤϯδχΞੵۃ࠾༻தͰ͢ɻ ਓ໨ͷΤϯδχΞΛ୳͍ͯ͠·͢ʂ ΤϯδχΞਓͰ͕Μ͹͍ͬͯ·͢ɻ ৽͍͠΋ͷେ޷͖ ࠊ͕ॏ͍