First blood

Let’s start with some really basic examples. It’s Hello World! time.

Hello

Implement method present in class Hello so that it conforms to outputs defined in HelloSpec.

Hello().present("world")

should output

Hello world

Definition of done: HelloSpec test must pass.

Data classes

Use data class for implementing Person as a simple POKO (Plain Old Kotlin Object ;)). It should have these properties:

firstName: String
lastName: String
age: Int
hobbies: List<String>

Definition of done: DataClassesSpec test must pass.

Reference: https://kotlinlang.org/docs/reference/data-classes.html

Inheritance

This example should give you an overview on what’s the Kotlin’s approach to inheritance. The main idea is that all classes are by default final, as well as all methods. To make class extendable you must mark it as open (or abstract if you want it to be abstract) and define all overridden methods by override keyword.

Wire up the class hierarchy defined in Inheritance.kt file as follows:

  • TextFile and BinaryFile are FileResources
  • FileResource cannot be instantiated
  • BinaryFile is Streamable
  • Bonus: Implement method FileResource.toFile() to your liking.

Definition of done: Just make sure you understand the essence.

Reference: https://kotlinlang.org/docs/reference/classes.html

Super phun time with collections

When using Kotlin you will be encouraged to use immutable* structures whenever possible (e.g. prefer listOf over arrayListOf). Also, working with collection transformations, map-reducing values, filtering and so on is fairly easy and extremely readable.

Pro tip: Use the it keyword in lambdas to reference single parameter of a function

There are three extension functions defined on the lists. Implement them according to description in FunWithCollections.kt.

Definition of done: FunWithCollectionsSpec tests must pass.

*immutable-ish, based on opiniated experts’ agreement

Topics:

First blood

Let’s start with some really basic examples. It’s Hello World! time.

Hello

Implement method present in class Hello so that it conforms to outputs defined in HelloSpec.

Hello().present("world")

should output

Hello world

Definition of done: HelloSpec test must pass.

Data classes

Use data class for implementing Person as a simple POKO (Plain Old Kotlin Object ;)). It should have these properties:

firstName: String
lastName: String
age: Int
hobbies: List<String>

Definition of done: DataClassesSpec test must pass.

Reference: https://kotlinlang.org/docs/reference/data-classes.html

Inheritance

This example should give you an overview on what’s the Kotlin’s approach to inheritance. The main idea is that all classes are by default final, as well as all methods. To make class extendable you must mark it as open (or abstract if you want it to be abstract) and define all overridden methods by override keyword.

Wire up the class hierarchy defined in Inheritance.kt file as follows:

  • TextFile and BinaryFile are FileResources
  • FileResource cannot be instantiated
  • BinaryFile is Streamable
  • Bonus: Implement method FileResource.toFile() to your liking.

Definition of done: Just make sure you understand the essence.

Reference: https://kotlinlang.org/docs/reference/classes.html

Super phun time with collections

When using Kotlin you will be encouraged to use immutable* structures whenever possible (e.g. prefer listOf over arrayListOf). Also, working with collection transformations, map-reducing values, filtering and so on is fairly easy and extremely readable.

Pro tip: Use the it keyword in lambdas to reference single parameter of a function

There are three extension functions defined on the lists. Implement them according to description in FunWithCollections.kt.

Definition of done: FunWithCollectionsSpec tests must pass.

*immutable-ish, based on opiniated experts’ agreement