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

Kotlin für Android-Entwickler

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Kotlin für Android-Entwickler

JavaLand2016

Avatar for Benedict

Benedict

March 08, 2016

Other Decks in Programming

Transcript

  1. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Kotlin JetBrains Android-Studio, Intellij IDEA Expressive Write more with less code Null safe Optionals Functional Lambdas JVM Bytecode 100% interoperable with Java Open Source Compiler, Plugins, Build tools
  2. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Why not <insert another JVM language here>? - Low learning curve - Perfect Android-Studio IDE support - Small library size (950KB) - Can be mixed with Java Open Repos on GitHub (JetBrains’ projects excluded)
  3. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Wait for OpenJDK? The Future: OpenJDK with Android N - Alternative: Libraries like “Retrolambda” or “StreamSupport” The Past: Java 7 - Released 2011 - Android support since 2013 (API 19) - ca. 70,8% devices supporting Java 7
  4. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Basic Syntax Name Function Parameter 1 Name Parameter 1 Type Return Type No Semicolon
  5. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Val and Var - var (variable) = mutable - val (value) = immutable - Like final in Java - Parameters are val - val is thread safe - Use val as much as possible!
  6. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Basic Types - Everything is an object! - The compiler can determine the types
  7. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Classes Getter and Setter Only Getter
  8. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Data classes - Avoid Boilerplate - Keep state - equals() - hashCode() - copy()
  9. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Visibility Modifiers - private - protected - internal - “inside this module” - public - default modifier
  10. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Named and default parameters
  11. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Null safety - Optionals No problem in Java: We MUST be Optionals if the object can be null at any time:
  12. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Null safety – Safe call operator Smartcast
  13. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Null safety - Elvis operator („?:“)
  14. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Install Kotlin - Preferences -> Plugins - Install Kotlin Plugin
  15. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Kotlin Android Extension - With Kotlin 1.0 Beta 3 merged into the main Kotlin Plugin - Synthetic properties to access layout widgets
  16. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Anko - DSL for UI creation - Many extensions included - Doesn’t work with fragments
  17. Kotlin für Android-Entwickler Benedict Pregler Kot lin Synt ax Kot

    lin and Android D emo Demo GitHub: https://github.com/BenedictP/RocketLeagueStatistics or https://github.com/a-frank/NotesKotlin