loading...
Cover image for How to become Effective with Kotlin? Answers from Marcin Moskala

How to become Effective with Kotlin? Answers from Marcin Moskala

jmfayard profile image Jean-Michel Fayard 🇫🇷🇩🇪🇬🇧🇪🇸🇨🇴 Updated on ・5 min read

The joy of Kotlin (4 Part Series)

1) with(ConfigObject) { "Language $KOTLIN".isSparkingJoy() } 2) Best ways to learn Kotlin in 2020: browser vs IDE, books vs tutorials, for newbies and Java devs 3) How to become Effective with Kotlin? Answers from Marcin Moskala 4) From marketing to backend developer in one year - the story of Adele Carpenter

Marcin Moskala is an experienced developer and Kotlin trainer.

He is an official JetBrains partner for Kotlin training, founder of Kt. Academy and main author on Kt. Academy technical blog . He is a speaker at tech conferences. I met him at KotlinConf 2018 where he had talked about Effective Multiplatform Kotlin Development. He is the author of the book Android Development with Kotlin and recently released Effective Kotlin. We share a common curiosity about everything releated to learning and mentoring, so I asked him to answer a few questions for you.

Who are you?

Marcin, can you first tell us a bit about you personally? Who are you as a person and what makes you tick?

This is an interesting and important question I have been asking myself lately. What I think truly makes me tick is learning. I love learning and I spend a lot of time on that - researching, reading, learning from flashcards, trying new approaches… It makes me feel great and it makes me think. As a result, I am having a lot of ideas and knowledge to share, and when I have them I feel I need to check ideas and share the knowledge. So I write, teach, speak, etc. It is clearly not the only mechanism that drives me, but in retrospection, I think that this one is quite strong and in big part led my last years.

On Training

I feel that most IT companies are under-investing in Training. Sure, there is an infinite amount of information on the internet, and given an infinite amount of time, a developer team can learn everything on its own. But Time is, in fact, our most precious resource. Can you talk about your experience working as a Kotlin trainer?

Yes, training can speed-up the learning process.

What I think is even more important is that it triggers the whole team to start using a new tool. So practically all the teams I trained reported to me that they started using Kotlin everywhere straight after my workshop.

Another thing is that it motivates us to learn things people often forget about. Too often people just copy-paste without understanding.

A simple example: Say that you use Gradle. Learning how it works might probably make your life easier in the long term. It is possible - there are some good fee Gradle courses and materials on the internet. But people generally assume they don’t have time for that. Although if they join a workshop, they have time dedicated for that and they can truly learn that in depth.

How to write a programming book that stays relevant?

You just released your second book: Effective Kotlin. I know some devil advocates that say that programming books are useless because their content gets quickly obsoleted. I think they are wrong for example for beginners’ books, those are really useful. But your book is aimed at experienced developers. What strategy did you choose to make sure your book stays relevant as Kotlin evolves?

I was actually thinking a lot about it as I observed that most Effective Java items are not relevant in Kotlin or could be solved with good warnings instead of developers remembering the best practices.

Though then I noticed that my favorite items are not Java-specific at all:

  • Favor composition over inheritance,
  • Design, and document for an inheritance, or else prohibit it,
  • Minimize the accessibility of classes and members,
  • Minimize mutability.

So I decided to describe more general concepts that are important in Kotlin.

In most items, I am explaining general timeless rules and showing how do they apply in Kotlin.

Those who finished the first chapter on Safety might recognize that I present the idea of explicitly stated preconditions and postconditions and that in Kotlin we express them using require, check and assert.

Or the idea of defensive and offensive programming and how they are applied in Kotlin to eliminate nullability.

It is especially true for chapters 3 and 4 which describe many high-level concepts.

There are some items that might change over time.

For instance, since function interfaces were introduced to Kotlin, we need to rethink as a community when should we use function types and where function interfaces instead.

Effective Kotlin

After you gave me an instance of "Effective Kotlin" at KotlinConf, five people stopped me to ask where they can grab their versions. So I can attest from first-hand experience that there is a demand for your book. Where should my readers go to find it?

Polish

Andrey Breslav made you smile during his keynote by saying that the focus was now to make Kotlin more POLISH. Can you tell the non-Polish among us what the Kotlin community looks like in Poland?

Well, probably it was totally accidental, but as a polish, I had to catch that word-game. About the community, there are many great conferences organized in Poland. I think it is a perfect place for conferences: in the middle of Europe, part of the EU, highly civilized and English speaking, and yet relatively cheap.

Although I am a bit disappointed about the Warsaw community. There are many Kotlin-related events in Krakow and Wroclaw, but not so many in Warsaw. I hope to change it, and so I support local communities and I started organizing a new conference we call Kotlin Day and Night. We are now talking with sponsors, but it seems that we will be able to organize the first edition in Oct 2020.

Underhyped projects

Do you have any favorite-but-not-well-known Kotlin project that deserves in your opinion more publicity?

In general, I think that in our community we have an effective flow of ideas.

One project I think is underestimated is MockK which is a powerful and multiplatform alternative to Mockito. It’s the only problem is a few sec startup time, but except for that, it is much more convenient and featured than any other mocking framework I ever used.

There are a few nice project examples like Igor’s Android-Showcase or Saket’s Press.

GitHub logo mockk / mockk

mocking library for Kotlin

mockk kotlin

Gitter Relase Version Change log codecov Weekly users Android Matrix tests Open Source Helpers

Kotlin Academy articles

Check the series of articles "Mocking is not rocket science" at Kt. Academy describing MockK from the very basics of mocking up to description of all advanced features.

Spring support

Kotlin version

From version 1.10.0 MockK does not support Kotlin 1.2.*

Known issues & worth to remember

  • Some known issues related to Kotlin 1.3, Gradle 5 and Spring Boot were fixed in MockK 1.9. Please report if you face any problems.
  • PowerMock needs a workaround to run together with MockK #79. (not sure after workaround if it is generally usable or not, please somebody report it)

Table of contents:

  • auto-gen TOC {:toc}

Examples & articles

GitHub logo igorwojda / android-showcase

💎 Android application following best practices: Kotlin, coroutines, Clean Architecture, feature modules, tests, MVVM, static analysis...

Android showcase

Kotlin Version AGP Gradle

codebeat badge Codacy Badge CodeFactor

Showcase is a sample project that presents a modern, 2020 approach to Android application development with up to date tech-stack.

The goal of the project is to demonstrate best practices by using up to date tech-stack and presenting mod ern Android application Architecture that is modular, scalable, maintainable, and testable. This application may look quite simple but it has all of these small details that will set the rock-solid foundation for the larger app suitable for bigger teams and long application lifecycle.

This project is being maintained to match current industry standards. Please check CONTRIBUTING page if you want to help.

Project characteristics

This project brings to table set of best practices, tools, and solutions:

GitHub logo saket / press

A cross-platform markdown editor written in Kotlin Multiplatform (work in progress)

Press is a wysiwyg writer for crafting notes inspired by Bear. It uses markdown for styling and formatting text with a beautiful inline preview.

Press was created as a proof-of-concept for exploring Kotlin Multiplatform, as well as the author’s frustration from the lack of minimal markdown note taking apps that work on all platforms, especially Android and macOS. If you relate to either of these reasons, Press is looking for contributors.

Documentation

Contributing

Press is a barebones app right now and there are many improvements to make. The first steps would be setting up the iOS app, followed by macOS. Take a look at the open issues and feel free to…




Contact

Where can people reach you if they want to know more?

For public questions, https://twitter.com/marcinmoskala is the best place. For private ones on conferences.

If you need technical help, I suggest Kotlin Slack public channels or Stack Overflow.

There are many experts there ready to help.

The joy of Kotlin (4 Part Series)

1) with(ConfigObject) { "Language $KOTLIN".isSparkingJoy() } 2) Best ways to learn Kotlin in 2020: browser vs IDE, books vs tutorials, for newbies and Java devs 3) How to become Effective with Kotlin? Answers from Marcin Moskala 4) From marketing to backend developer in one year - the story of Adele Carpenter

Discussion

markdown guide