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

Getting to 100% Kotlin: A practical guide

Dan Kim
September 25, 2017

Getting to 100% Kotlin: A practical guide

A lot of teams are super excited by Kotlin and are ready to go all-in with it. But while exciting, it can also be stressful — learning a brand new language while converting old code and writing new features, all at the same time? How does a team get there as smoothly as possible?

We’re here to help! At Basecamp we’ve worked hard to make our codebase 100% Kotlin over the course of the last year. We learned a lot and want to share a roadmap of how you can get there too.

If you're just starting out with Kotlin but can already see its potential, this talk is for you. We’ll share our best overarching strategies and tips based on a year of real-world shipping — how to get started, how to keep moving forward, and pitfalls to keep an eye out for.

No theory here, this is all based on our actual experiences getting to 100% Kotlin.

(Talk given at Android Summit 2017 on 8/24/17 and Droidcon NYC 2017 on 9/25/17)

Dan Kim

September 25, 2017
Tweet

More Decks by Dan Kim

Other Decks in Programming

Transcript

  1. Start with small conversions ✅ Adapters ✅ POJOs / Models

    ✅ Util methods Entire Retrofit implementation
  2. fun processAccounts(accounts: List<Account>?) {
 for (account in accounts!!) {
 if

    (account.active) {
 ...
 } else if (account.trial) {
 ...
 } else {
 ...
 }
 }
 }
  3. fun processAccounts(accounts: List<Account>?) {
 for (account in accounts!!) {
 if

    (account.active) {
 ...
 } else if (account.trial) {
 ...
 } else {
 ...
 }
 }
 }
  4. fun processAccounts(accounts: List<Account>?) {
 for (account in accounts!!) {
 if

    (account.active) {
 ...
 } else if (account.trial) {
 ...
 } else {
 ...
 }
 }
 }
  5. fun processAccounts(accounts: List<Account>?) {
 for (account in accounts!!) {
 if

    (account.active) {
 ...
 } else if (account.trial) {
 ...
 } else {
 ...
 }
 }
 }
  6. fun processAccounts(accounts: List<Account>?) {
 for (account in accounts!!) {
 if

    (account.active) {
 ...
 } else if (account.trial) {
 ...
 } else {
 ...
 }
 }
 }
  7. fun processAccounts(accounts: List<Account>?) {
 for (account in accounts!!) {
 if

    (account.active) {
 ...
 } else if (account.trial) {
 ...
 } else {
 ...
 }
 }
 }
  8. fun processAccounts(accounts: List<Account>?) {
 for (account in accounts!!) {
 if

    (account.active) {
 ...
 } else if (account.trial) {
 ...
 } else {
 ...
 }
 }
 }
  9. Find a few key concepts that click *for you* ✅

    Flow control ✅ Collections ✅ Extension functions
  10. fun success(inboxItems: InboxItems) {
 val items = inboxItems.filterNot { ...

    } 
 doAsync { CachePrefs.setInboxCache(context, items) }
 }
  11. fun success(inboxItems: InboxItems) {
 val items = inboxItems.filterNot { ...

    } 
 doAsync { CachePrefs.setInboxCache(context, items) }
 }
  12. fun success(inboxItems: InboxItems) {
 val items = inboxItems.filterNot { ...

    } 
 doAsync { CachePrefs.setInboxCache(context, items) }
 }
  13. fun success(inboxItems: InboxItems) {
 val items = inboxItems.filterNot { ...

    } 
 doAsync { CachePrefs.setInboxCache(context, items) }
 }
  14. fun success(inboxItems: InboxItems) {
 val items = inboxItems.filterNot { ...

    } 
 doAsync { CachePrefs.setInboxCache(context, items) }
 }