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

Kotlin学習とライブラリ作成

800912a73ce4e879003b6c89cf80cfeb?s=47 yagi
March 24, 2016

 Kotlin学習とライブラリ作成

ライブラリ作成をしながらKotlinを学習するといいんじゃないかなーという話です

800912a73ce4e879003b6c89cf80cfeb?s=128

yagi

March 24, 2016
Tweet

Transcript

  1. ,PUMJOֶशͱϥΠϒϥϦ࡞੒ 2016 03 24 @ Sansan Toshihiro Yagi

  2. About Me Toshihiro Yagi Twitter : sys1yagi Programmer at Cookpad

    Inc. Android engineer Kotlin͸2014೥ॳ಄ลΓ͔ΒŧŔŕŪ৮͍ͬͯΔఔ౓
  3. Target & Agenda ,PUMJOֶशͷͨΊʹϥΠϒϥϦ࡞ͬͯΈΔͷ͸݁ ߏ͍͍Μ͡Όͳ͍͔ͳʔͱ͍͏࿩Ͱ͢ɻ LNPDLJUPͱ͍͏ϥΠϒϥϦͱڞʹ࡞੒࣌ʹ࢖ͬ ͨ,PUMJOͷػೳͳͲΛ঺հ͠·͢ɻ ,PUMJOͷجຊతͳݴޠͷػೳ͸஌͍ͬͯͯ,PUMJO Λ࢖ͬͯ۩ମతʹͲ͏͍ͬͨࣄ͕Ͱ͖ͦ͏͔ͳ͊ʔ ͱߟ͍͑ͯΔਓ޲͚

  4. What is kmockito?

  5. Wrapper of Mockito for Kotlin NPDL WBSJUFN*UFNNPDL  XIFO JUFNMFOHUI

    JOWPLFEUIFO3FUVSO   BOTXFS JUFNTPNF.FUIPE BOZ*OU BOZ4USJOH BOZ BOZ  JOWPLFE UIFO"OTXFS\ WBM B C D E JUBSHVNFOUT*OU 4USJOH *UFN /BNF  EPTPNFUIJOH ^ WFSJGZ JUFNWFSJGZ UJNFT  MFOHUI https://github.com/sys1yagi/kmockito
  6. Motivation

  7. bXIFO`͸,PUMJOͷ༧໿ޠ WBMJUFNNPDL *UFNDMBTTKBWB  AXIFOA JUFNMFOHUI UIFO3FUVSO  ༧໿ޠͱඃΒͳ͍Α͏ʹΤεέʔϓ͕ඞཁ ৑௕

  8. BOZ ͕OVMMΛฦ͢ AXIFOA JUFNMFOHUI BOZ UIFO3FUVSO ʜ any() return null

    and cause runtime error GVOMFOHUI UFYU4USJOH *OU\ʜ^ Non-Null
  9. Yes kmockito!

  10. Using features of Kotlin top-level extensions inline and reified Extension

    Properties Destructuring Declarations
  11. top-level extensions

  12. τοϓϨϕϧʹؔ਺͕ॻ͚ͯศར

  13. TUBUJDϝιου܈Λ࣋ͭΫϥε͕ੜ੒͞ΕΔ ֦ுؔ਺܈͸XX_extension.ktʹूΊΔͱΑͦ͞͏

  14. lnline & reified

  15. ৑௕ͳܕͷهड़Λ΍ΊΔ WBMJUFNNPDL *UFNDMBTTKBWB WBMJUFN*UFNNPDL  JUFNMFOHUI NPDL

  16. ৑௕ͳܕͷهड़Λ΍ΊΔ GVO5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB

  17. ৑௕ͳܕͷهड़Λ΍ΊΔ GVO5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB ܕফڈʹΑͬͯΤϥʔ

  18. ৑௕ͳܕͷهड़Λ΍ΊΔ GVO5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB ܕফڈʹΑͬͯΤϥʔ JOMJOFGVOSFJpFE5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB

  19. ৑௕ͳܕͷهड़Λ΍ΊΔ GVO5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB ܕফڈʹΑͬͯΤϥʔ JOMJOFGVOSFJpFE5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB JOMJOFԽͯ͠ܕύϥϝʔλʹSFJpFEΛ෇༩͢Δͱ5Λ۩৅ܕͱ͔ͯ͋ͭ͑͠Δ ˞LPUMJOSFqFDU͕ඞཁͰ͢

  20. ৑௕ͳܕͷهड़Λ΍ΊΔ JOMJOFGVOSFJpFE5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB WBMJUFN*UFNNPDL  JUFNMFOHUI NPDL :FT

  21. Extension Properties

  22. ৑௕ͳϝιουݺͼग़͠Λ΍ΊΔ GVO55JOWPLFE .PDLJUPAXIFOA UIJT JUFNMFOHUI JOWPLFE UIFO3FUVSO 

  23. ৑௕ͳϝιουݺͼग़͠Λ΍ΊΔ GVO55JOWPLFE .PDLJUPAXIFOA UIJT JUFNMFOHUI JOWPLFE UIFO3FUVSO  ͳͯ͘΋Α͘ͳ͍ʁ

  24. ৑௕ͳϝιουݺͼग़͠Λ΍ΊΔ GVO55JOWPLFE .PDLJUPAXIFOA UIJT  WBM55JOWPLFE0OHPJOH4UVCCJOH5 HFU JOWPLFE ɾ&YUFOTJPO1SPQFSUJFTͰ೚ҙͷΫϥεʹϓϩύςΟΛ෇༩͢Δ ɾϓϩύςΟΞΫηε࣌ʹϝιουݺͼग़͠

  25. ৑௕ͳϝιουݺͼग़͠Λ΍ΊΔ GVO55JOWPLFE .PDLJUPAXIFOA UIJT  WBM55JOWPLFE0OHPJOH4UVCCJOH5 HFU JOWPLFE ɾ&YUFOTJPO1SPQFSUJFTͰ೚ҙͷΫϥεʹϓϩύςΟΛ෇༩͢Δ ɾϓϩύςΟΞΫηε࣌ʹϝιουݺͼग़͠

    JUFNMFOHUI JOWPLFEUIFO3FUVSO 
  26. Destructuring Declarations

  27. 85' JUFNTPNF.FUIPE BOZ*OU BOZ4USJOH BOZ BOZ  JOWPLFE UIFO"OTXFS\ WBMBJUBSHVNFOUT<>BT*OU

    WBMCJUBSHVNFOUT<>BT4USJOH WBMDJUBSHVNFOUT<>BT*UFN WBMEJUBSHVNFOUT<>BT/BNF EPTPNFUIJOH ^
  28. %FTUSVDUVSJOH%FDMBSBUJPOT Λ࢖ͬͨ୅ೖ WBM B C 1BJS l)FMMPz   Bl)FMMPz

    C
  29. %FTUSVDUVSJOH%FDMBSBUJPOT Λ࢖ͬͨ୅ೖ WBM B C 1BJS l)FMMPz   Bl)FMMPz

    C ಛఆͷϧʔϧʹԊͬͨΫϥεͰ %FTUSVDUVSJOH%FDMBS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let’s Enjoy Kotlin life ϥΠϒϥϦΛ࡞ͬͯ

  37. ͓·͚

  38. ಉ͡Α͏ͳϥΠϒϥϦཚཱ໰୊ ͏ʔΜͲ͏ͨ͠΋ͷ͔

  39. "XFTPNFLPUMJO ͜͜ʹೖΓ͍ͨ໰୊ https://github.com/JavaBy/awesome-kotlin

  40. ؤுΖ͏