How “Effective Java” may have influenced the design of Kotlin — Part 1
Lukas Lechner
44612

Thank you for the great post!

But I don’t agree that Kotlin’s default parameters is a good alternative to the Builder pattern. The problem that Builder solves not only with too many constructor parameters — you can create constructor in Java which requires only the part of fields and assign default values to the rest of them. The second problem is the meaning and the order of constructor’s parameters. Imagine that we have a class with 10 final Integer fields which all must be passed to constructor. Its very difficult to the user of this class to understand what each of this parameters mean and in what order they must be passed to the constructor. This is the main problem which Builder patters solves — it allows you to provide methods with meaningful names that show the user which specific parameter she passes to the constructor and makes the order of passing those parameters unimportant.