October 2019
Intermediate to advanced
434 pages
11h 54m
English
To solve the same problems as the Builder pattern in Kotlin, we can turn to default parameter values and named arguments. Remember that the key problem the Builder pattern solves is allowing client code to easily configure different representations of some class without having to know about or understand any optional parameters that are not relevant to current usage. This is something that functions in Kotlin provide out of the box through default parameter values and named arguments. Let's take a look at how we could rewrite our SearchRequest class in Kotlin to make it easier to configure without the use of a Builder.
To achieve the same results in Kotlin, we can reimplement SearchRequest using ...
Read now
Unlock full access