ursus
11/27/2021, 1:30 AMdata class PhoneNumber(val normalized: String)
and I need to format it with spaces etc before rendering in UI
Is this a member or extension function?Stephan Schroeder
11/27/2021, 10:40 AM@JvmInline value class PhoneNumber(val normalized: String)
, since this would avoid the wrapper overhead while retaining the type-safety. That only works on the JVM, of course. For other backends data class
is fine.
More info: https://kotlinlang.org/docs/inline-classes.htmlursus
11/27/2021, 2:56 PMDaniel
11/27/2021, 8:57 PMPhoneNumberFormatter
class. This way the formatting is nicely encapsulated and you can mock it in unit tests if need beisNotEmpty
) and domain specific lends itself more to member functions or other classes.Jacob
11/28/2021, 1:10 AMgildor
11/28/2021, 8:52 AM