Three weeks ago I started a side project in Kotlin that could potentially replace a legacy Java code I created a couple of years ago. I'm very curious on how easy it'll be to integrate it in the whole solution, as well as how the classic GoF patterns will be applied in Kotlin.
One of the most salient features of our Tech Hiring culture is that there is so much bullshit. Everyone knows this. Each of us contributes his share. But we tend to take the situation for granted.
One of the most salient features of our Tech Hiring culture is that there is so much bullshit. Everyone knows this. Each of us contributes his share. But we tend to take the situation for granted.
So actually the builder pattern is integrated in Kotlin itself.
Given data class User(val id: Int = 1, val name: String = "")
Then this do the same as the builder pattern would do in Java val user = User(name = "Alejandro", id =42)
The dialog function is a building block for building a DSL.
It takes as parameter a function init that you could define as having a parameter DialogBuilder and returning Unit. But instead you define the parameter as an extension function of DialogBuilder.
Thank you for your response. This makes sense.
Three weeks ago I started a side project in Kotlin that could potentially replace a legacy Java code I created a couple of years ago. I'm very curious on how easy it'll be to integrate it in the whole solution, as well as how the classic GoF patterns will be applied in Kotlin.
Cheers and thanks for sharing.
You may be interested by this:
github.com/dbacinski/Design-Patter...
Hey, builder pattern is interesting....
I'm trying to understand this expression:
fun dialog(init: DialogBuilder.() -> Unit): Dialog =
DialogBuilder(init).build()
The part that is kind of weird to me is: DialogBuilder.()
Is that related to the extension functions?
So actually the builder pattern is integrated in Kotlin itself.
Given
data class User(val id: Int = 1, val name: String = "")
Then this do the same as the builder pattern would do in Java
val user = User(name = "Alejandro", id =42)
The
dialog
function is a building block for building a DSL.It takes as parameter a function
init
that you could define as having a parameterDialogBuilder
and returningUnit
. But instead you define the parameter as an extension function ofDialogBuilder
.kotlinlang.org/docs/reference/lamb...