Created
February 4, 2022 14:11
-
-
Save ngallazzi/7c21c3144a2aacd227fc6ceb48483243 to your computer and use it in GitHub Desktop.
Mastering refactoring - Introduce parameter object, final code
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
private fun printInvoiceHeader(header: InvoiceHeader) { | |
binding.tvInvoicePreview.text = header.toString() | |
} | |
data class InvoiceHeader(private val number: Int, private val date: LocalDate) { | |
override fun toString(): String { | |
return "INVOICE N° ${number}, ${formatter.format(date)}\n\n" | |
} | |
companion object { | |
val formatter: DateTimeFormatter = DateTimeFormatter.ISO_DATE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment