DEV Community


Discussion on: Builder pattern in Kotlin

jmfayard profile image
Jean-Michel Fayard πŸ‡«πŸ‡·πŸ‡©πŸ‡ͺπŸ‡¬πŸ‡§πŸ‡ͺπŸ‡ΈπŸ‡¨πŸ‡΄ • Edited

Well you don't need this
The builder pattern is integrated in Kotlin in the language itself.
Define a normal data class with immutable properties, that's it, you have exactly what you needed in Java when you needed a builder class.
The only case for using the actual Java builder pattern is if you release a Kotlin library and want to provide this feature to Java programmers.