This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// domain: | |
class PhoneNumber(val value: String) | |
class Contact(val phoneNumber: PhoneNumber) | |
// screen: | |
class PhoneNumberScreen( | |
private val phoneNumber: PhoneNumber | |
) { | |
fun render() { | |
println("Phone number: ${phoneNumber.value}") | |
} | |
} | |
// presentation layer: | |
fun main() { | |
val contact = Contact(PhoneNumber("12345")) | |
show(contact.phoneNumber) // "Phone number: 12345" | |
val contactWithInvalidPhoneNumber = Contact(PhoneNumber("")) | |
show(contactWithInvalidPhoneNumber.phoneNumber) // "Phone number: " | |
} | |
private fun show(phoneNumber: PhoneNumber) { | |
val phoneNumberScreen = PhoneNumberScreen(phoneNumber) | |
phoneNumberScreen.render() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment