O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Kotlin for Android & Java Developers: Clean Code on Android

Video Description

Become a professional Kotlin developer and write cleaner code in your Android apps than in Java, avoid boilerplate code

About This Video

  • This course will focus on producing clean code which teaches you to make use of Kotlin's amazing features to actually write better code than in Java.
  • Get a huge benefit using Kotlin instead of Java, e.g. by avoiding boilerplate code around many Android APIs.

In Detail

Kotlin is a modern language for the JVM, and the only officially supported language on Android besides Java. It's developed by JetBrains, the makers of IntelliJ on which Android Studio is based. Since Google's announcement to officially support Kotlin in 2017, interest in the language has radically increased -- and with it the number of tutorials, courses, books, and also job offers for Kotlin. It's a great time to dive into this modern language and get ahead of other Android developers! With its modern language design that incorporates industry best practices, Kotlin allows you to write highly expressive, understandable and safe code -- while being 100% interoperable with Java. You can use any Java classes and methods from Kotlin and the other way around. This course shows you what language features I mean, and how you can apply them in order to write world-class code. Learn to use Kotlin the right way to actually improve your Android app code write null-safe, concise, and readable code in Kotlin using functional and object-oriented concepts workaround unnecessary boilerplate code when using Android APIs (e.g. SQLite) using higher-order extension functions, use Android Studio effectively to speed up your development workflow, get your questions answered along the way should you ever get stuck.

Table of Contents

  1. Chapter 1 : Introduction
    1. What You'll Learn in this Course 00:04:51
    2. Make the Most of this Course! 00:02:44
    3. Who's Using Kotlin? 00:02:52
  2. Chapter 2 : Get Ready
    1. Introduction 00:01:44
    2. Install the Java JDK 8 00:03:12
    3. Install Android Studio 00:07:11
    4. Set Up a Project in Android Studio 00:12:05
    5. Recap 00:00:28
  3. Chapter 3 : Kotlin Basics
    1. Introduction 00:01:27
    2. Variables and Data Types 00:08:27
    3. Null Safety in Kotlin 00:08:56
    4. Conditionals: "if" Expressions 00:08:20
    5. Conditionals: "when" Expressions 00:08:36
    6. Collections 00:09:42
    7. "for" Loops 00:05:16
    8. "while" Loops 00:03:42
    9. Functions 00:06:22
    10. Get Ready for Serious Kotlin Coding (Set up IntelliJ IDEA) 00:04:59
    11. Create a main() Function 00:02:33
    12. Named Arguments & Default Parameter Values 00:05:44
    13. Exceptions 00:06:13
    14. Why No Checked Exceptions? 00:05:31
    15. Recap 00:01:53
  4. Chapter 4 : Functional Programming
    1. Introduction 00:01:23
    2. What is Functional Programming? 00:03:11
    3. Functional Programming II 00:04:15
    4. Lambdas & Higher-Order Functions 00:10:06
    5. Use map() and flatMap() 00:07:47
    6. Use take () and drop() 00:06:28
    7. Use zip () 00:04:45
    8. Chain Functions Together 00:06:19
    9. Lazy Sequences 00:08:17
    10. Case Study: Performance of Lazy Sequences 00:08:10
    11. Code Along: Infinite Lazy Sequence of All Prime Numbers 00:12:29
    12. Use "let" Operator for Scoping and Nullables 00:06:26
    13. Use "with" for Many Calls on the Same Object 00:03:55
    14. Use "use" for Closeable (like try-with-resources) 00:04:30
    15. Inline Functions 00:06:59
    16. Recap 00:02:23
  5. Chapter 5 : Object-Orientation in Kotlin
    1. Introduction 00:01:59
    2. Classes 00:02:27
    3. Properties with Getters & Setters 00:06:01
    4. Primary and Secondary Constructors 00:08:26
    5. Methods 00:03:47
    6. Extension Functions 00:06:23
    7. Data Classes 00:09:51
    8. Enums 00:06:12
    9. Inheritance 00:05:21
    10. Code Along: Inheritance Example 00:05:57
    11. Abstract Classes 00:05:47
    12. Interfaces 00:07:18
    13. Overriding Rules 00:08:52
    14. Smart Casts 00:07:56
    15. Visibilities 00:08:48
    16. Companion Objects for "Static" Members 00:06:31
    17. Object Declarations as Singletons 00:05:09
    18. Packages and Imports 00:04:15
    19. Generic Classes 00:07:53
    20. Generic Functions 00:04:59
    21. Covariance 00:07:07
    22. Covariance: Java vs Kotlin 00:10:35
    23. Covariance vs. Contra variance: "out" and "in" 00:09:44
    24. Recap 00:01:47
  6. Chapter 6 : Kotlin for Android – Fundamentals
    1. Introduction 00:02:50
    2. Create the App Project 00:04:52
    3. Understand the Android Versions 00:03:08
    4. Create a CardView Layout and Add UI Elements 00:09:44
    5. Use the "Kotlin Android Extensions" 00:08:55
    6. Challenge Solution 00:03:31
  7. Chapter 7 : Kotlin for Android -- Implement a RecyclerView
    1. Introduction 00:01:01
    2. What is a RecyclerView? 00:05:17
    3. Create the Data Class "Habit" 00:04:22
    4. Implement the "HabitsAdapter" - Part I 00:05:01
    5. Implement the "HabitsAdapter" - Part II 00:03:36
    6. Implement the "HabitsAdapter" - Part III 00:09:44
  8. Chapter 8 : Kotlin for Android -- Let Users Create Habits
    1. Introduction 00:01:36
    2. Add a Menu 00:01:57
    3. Add a Second Activity 00:03:10
    4. Use Intents to Switch Activities 00:07:14
    5. Challenge Solution 00:08:01
    6. Let Users Choose an Image 00:06:44
    7. Get the Selected Image Back (onActivityResult) 00:08:11
    8. Show Error Messages to the User 00:07:39
    9. Code Along: An Extension Function for "EditText" 00:03:43
  9. Chapter 9 : Kotlin for Android -- Use SQLite the Kotlin Way!
    1. Introduction 00:01:11
    2. Introducing SQLite 00:01:28
    3. Define the Contracts 00:04:14
    4. Implement the Database Helper 00:06:32
    5. Store a Habit to SQLite 00:08:03
    6. Implementing Secure Transactions (that support Rollback) 00:04:09
    7. Clean Code: Improving Transactions in Kotlin 00:06:51
    8. Clean Code: Further Improving Transactions and Performance 00:06:33
    9. Store the Habit in "CreateHabitActivity" 00:09:23
    10. Read All Habits from SQLite 00:09:01
    11. Challenge Solution 00:04:27
    12. Challenge Solution 00:07:58
    13. Add Files to the Virtual Device (Excursus) 00:01:43