DEV Community


Discussion on: Domain modeling obsession

tarodbofh profile image
Juan Ara

BTW, the Validated approach, though nice, hides for me a fear for null. Since you are using kotlin, a validateEmail(email: String) would just return a ValidatedEmail (inline) or null.
Embrace null! Null is a valid domain idea! Check
At that link there are a lot of references about idiomatic kotlin being direct style instead of railway style (though doesn't forbid the 2nd!):

However, core Kotlin language and its Standard Library are designed around a direct programming style in mind.
eureka84 profile image
Angelo Sciarra Author

I really like Kotlin nullable types because they force you to think about nullability and provides compile time checks against nullability.
I would use them maybe instead of data types like Option, because, as you said they are more idiomatic. I wouldn't go and use them in place of Eithers or Validated because they are currying other kinds of information and not simply the presence/absence of a value.