Mocking frameworks are powerful tools for testing and test driven development (TDD) in particular.
What are the rules to write good tests with mock objects?
Implementing the Decorator pattern with function composition and how would the Visitor pattern look like in Kotlin? From dev.to(), the DEV community.
Kotlin is getting more and more relevant. How would common design patterns implemented in Kotlin look like?
From dev.to(), the DEV community.
In Kotlin, using a function as a parameter of another function (so called higher-order functions) feels more natural than in Java.
Using lambdas has some disadvantages, though. Since they’re anonymous classes (and therefore, objects), they need memory (and might even add to the overall method count of your app).
To avoid this, we can
inline our methods.
Kotlin’s most powerful feature (compared to Java) are probably Extension Functions.
They allow you to add new functionality to an existing class, without using inheritance or reflection. You can define your own extension functions and Kotlin ships with a lot of pre-defined ones.
There are e.g. a lot extensions for collections, but also those that extend every class in your program. That’s right - every single class is extended by the functions in
When I started with Kotlin, I found them quite confusing. With this post, I hope to un-confuse them a little bit.
If you just started with Kotlin, there’s a good chance that you are overwhelmed with the new possibilities.
This is especially true if you originally came from Java, where concepts like Properties or Function Types simply do not exist.
In this post, I will address some of the questions concerning Properties a beginner might have when starting with Kotlin.
When updating a library or doing a big refactoring it quickly happens that we run against a massive wall of compiler errors. The Java compiler only displays around 100, so you never quite know how much progress you already made.
While trying to test-drive a RxJava app in Kotlin, I ran into some problems. Here are my notes on that topic.