During the workshop, we'll dive deeply into Kotlin best practices and idiomatic Kotlin use. We'll also talk about more general concepts like readability, abstraction design or contract setting.

The workshop is based on the book Effective Kotlin that is soon to be published. The content is well thought out and consulted with many Kotlin developers.

On the workshop you will:

Learn from lecture supported by slides

Solve coding challenges in Kotlin

Complete practical exercises

Solve Kotlin puzzlers

In the workshop we cover:

In the first 2 days, we cover general best practices and class design and the 3rd day is dedicated to code efficiency.

Most important best practices we'll be covering are:

Safety

  • Limit mutability
  • Eliminate platform types as soon as possible
  • Do not expose inferred types
  • Prefer composition over inheritance
  • Make it clear that top-level functions are not member functions

Readability

  • Design for readability
  • Use operator overloading methods as their names indicate
  • Consider naming arguments
  • Avoid returning or operating on Unit?
  • Specify variable type when it is not clear
  • Consider referencing receiver explicitly

Reusability

  • Do not repeat knowledge
  • Do not repeat common algorithms
  • Reuse between different platforms by extracting common modules

Design abstractions

  • Each function should be written in terms of a single level of abstraction
  • Define abstractions
  • Respect abstraction contract
  • Restrict visibility
  • Use abstraction to protect code against changes
  • Consider wrapping external API

Objects creation

  • Consider factory functions instead of constructors
  • Consider primary constructor with named optional arguments
  • Consider defining DSL for complex object creation

Class design

  • Use data modifier to represent a bundle of data
  • Use function types instead of interfaces to pass operations and actions
  • Do not use properties to express behaviour
  • Respect contract of equals
  • Respect contract of hashCode
  • Respect contract of compareTo
  • Respect contract of arithmetic operators

Make it cheap

  • Avoid unnecessary object creation
  • Consider inline modifier for higher-order functions
  • Eliminate obsolete object references
  • Use tail recursion to achieve efficient recurrence

Efficient collection processing

  • Prefer Sequence for bigger collections with more than one processing step
  • Consider Arrays with primitives for performance critical processing
  • Consider using mutable collections

On this way, we'll also review more advanced topics including:

  • Collections
  • Delegates
  • Platform types
  • Interoperability with Java
  • Typing system
  • Operator overloading
  • DSL creation
  • Functional programming
  • Computational complexity
  • Inline classes
  • Computational complexity
Marcin Moskała - Trainer in Kt. Academy

Learn from the best

Marcin Moskała

Marcin Moskała is an experienced Android developer, teacher, and an official Jetbrains' Kotlin training partner. He is the founder of Kt. Academy, author of the book "Android Development with Kotlin", and an active programming community member. He is also the main author on the biggest medium publication about Kotlin and a speaker invited to many programming conferences. Some of his talks can be found on YouTube, including:

Let's talk!

Tell us more about your needs and the level of your team, so we can adjust course material for you and send the right pricing.

Ask for pricing