brazilian-utils / kotlin

5 stars 0 forks source link

Open Mic "How Kotlin guys would like to use it?" #1

Open alexrochas opened 5 years ago

alexrochas commented 5 years ago

@andreoav, @hyanmandian, @guilhermecomum, @lucassveloso do you guys have idea of how Kotlin guys would use it? In Android probably?

What do you think, something like field validation?

data Person(
  @CPF val cpf: Long
)

Or something more explicity like composition or ihneritance (like a trait)?

class PersonController: Validatable (
  private validation: CPFValidation
)

Or even static?

fun validateFields() {
  Validations.validateCPF(someCPF)
}

And I didn't even thought about how someone would use with the DSL features kotlin have. 😆

andreoav commented 5 years ago

So.. I think you know Kotlin better than us. I just did the Kotlin version of Hello World.

But, from my experience, static is "bad"... hard to test, hard to mock, DI... and many other buzz words.

Which one more idiomatic to Kotlin? I know that those data classes are specific to Kotlin, but annotations feels too much Java for me.

As a JS/GoLang dev, I always prefer composition.