Hi!! I’ve tried to implement a Builder pattern des...
# announcements
m
Hi!! I’ve tried to implement a Builder pattern design in Kotlin but on internet find a different ways to do. Does anyone have an idea the best way to implement one? 😬 Thanks!!!
t
To use in kotlin or from other JVM languages?
m
For use in Kotlin and Android
c
Kotlin prefers the type-safe DSL-style builders to the traditional Java-style builders https://kotlinlang.org/docs/reference/type-safe-builders.html
m
??
t
It might be better to explain what you’re trying to achieve. The usual builder pattern isn’t usually required in kotlin due to defaults and named params
👆 7
c
Yeah default + named params are basically what the builder pattern does. I haven’t had a need for builders over the last 3ish years with Kotlin.
s
They are useful for wrapping crappy java APIs. Like the aws SDK builders.
t
The SDK builders are the builder pattern! I found it more useful to do a full on DSL for the AWS SDK