Skip to content

Instantly share code, notes, and snippets.

@ngallazzi
Last active February 3, 2022 17:41
Show Gist options
  • Save ngallazzi/72103b32863e2365398d4c617cddd115 to your computer and use it in GitHub Desktop.
Save ngallazzi/72103b32863e2365398d4c617cddd115 to your computer and use it in GitHub Desktop.
Mastering refactoring - Inline function, starting code
private fun printInvoiceSheet(invoice: Invoice) {
printInvoiceHeader(invoice)
val fullName = getFullName(invoice)
binding.tvInvoicePreview.append(fullName)
val address = getAddress(invoice)
binding.tvInvoicePreview.append(address)
}
private fun getFullName(invoice: Invoice): String {
val fullName =
"First Name: ${invoice.customer.firstName}\nLast Name: ${invoice.customer.lastName}\n"
return fullName
}
private fun getAddress(invoice: Invoice) : String {
val address = "Address: ${invoice.customer.address}\n"
return address
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment