AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Kotlin any9/14/2023 ![]() ![]() Fortunately, many patterns are built-in right into Kotlin’s language or its standard library. In Java, we have to write quite some boilerplate code to implemented certain idioms and patterns. Kotlin’s Built-in Support for Common Java Idioms and Patterns For instance, when you create a “train wreck” by trying to squeeze everything into a single unreadable expression. If overused, they can make our code even harder to read. Moreover, some Kotlin features should be used with sound judgment. Let’s see how we can write idiomatic Kotlin code and do things the Kotlin way.Ī word of warning: The following list is not exhaustive and does only express my humble opinion. Many of them can be replaced with better alternatives that are provided by Kotlin. In order to take full advantage of Kotlin, we have to revisit some best practices we got used to in Java. ![]() object for Stateless Interface Implementations.Refer to Constructor Parameters in Property Initializers.Concise Mapping with Single Expression Functions. ![]() apply() for Grouping Object Initialization.Named Arguments instead of Fluent Setter.Top-Level (Extension) Functions for Utility Functions.Kotlin’s Built-in Support for Common Java Idioms and Patterns.Java Ecosystem, Kotlin, Engineering Management, Sociology of Software Development Idiomatic Kotlin. ![]()
0 Comments
Read More
Leave a Reply. |