Kotlin properties – from basic to lazy

Kotlin has many things going for it, with one of the main qualities being its built-in null-safety. This guarantees that properties will always have a non-null value at runtime, greatly reducing the risks of coding errors and NullpointerExceptions. In languages where this isn’t the case — Java, anyone? — the lack of this feature is sometimes (ab)used by the libraries and frameworks we utilize (Spring and its property injection for instance).

This post will cover the way Kotlin deals with properties and their initialization.

Continue reading

Posted in Blog, Kotlin | Leave a comment

Do we need a whole new ekosystem?

There’s a joke that if you ask a developer to code a program to process widgets, they’d rather build a domain specific language and tool stack first to make life easier for when they might one day build the software that does the actual work.

A lot of development effort is under way to build a true Kotlin ecosystem: MockK for mocking, Kara for building web sites and Ktor for your obligatory asynchronicity. None of these frameworks let you do radically new things — they just do it the Kotlin way — but it’s proof that the language is gaining some real traction.

Continue reading

Posted in Blog, Kotlin | Tagged , | 1 Comment

Kotlin Quick Tip: Annotation targets

If you — like me — are a sucker for reducing boilerplate and are using JSR-303 – Bean Validation (I use it as part of Spring Boot) then you may have noticed how it can help you reduce validation boilerplate code. We can define REST endpoints on our application, which consume objects, that we can have Spring Boot automatically validate if we use the @Valid annotation.

Continue reading

Posted in Blog, Kotlin | Tagged , | Leave a comment

JMockit extensions for Kotlin

Sometimes you have to deal with existing libraries… also libraries that do not provide out-of-the-box support for Kotlin (bastards!). What do you do in such a scenario? Write your own 😉

In one of my recent projects we were using a mocking framework called: JMockit. We already had a lot of tests which were written using JMockit and we preferred not to switch to a different mocking framework.

Continue reading

Posted in Blog, Kotlin | Tagged | 3 Comments

Kotlin’s invoke: it looks like a duck, quacks like a duck, but isn’t a duck

SUMMARY: Kotlin has given us a fresh perspective on some very ingrained OO-habits, particularly the pervasive use of nouns for objects that have only one public method.
This article was originally posted on jaspersprengers.nl and published here with kind permission.

Speaking like a native

Pronouncing a foreign language so convincingly that you can pass for a native speaker is one of the hardest tricks to pull off. While it comes natural to young children it is something that very few adults ever master. That is because our ears have become attuned to the speech habits of our native language and we interpret every foreign language according to these patterns. Continue reading

Posted in Blog, Kotlin | Leave a comment