todd.ginsberg
02/08/2018, 8:10 PMAccount and perhaps a condensed version of the Account that contains a small fraction of the data in the full version.
Does it seem reasonable to have something like this (made up example)?
kotlin
data class AccountDto(login: String, firstName: String, lastName: String, city: String?, state: String?, zipCode: String?)
And then to convert it:
kotlin
fun AccountEntity.toDto(full: Boolean = true): AccountDto =
AccountDto(
login = this.login,
firstName = this.firstName,
lastName = this.lastName,
city = this.city.takeIf { full },
state= this.state.takeIf { full },
zipCode= this.zipCode.takeIf { full }
)
Or would it be more reasonable to have two versions of AccountDto (one for full view and one for limited)? The issue brought up was that takeIf { full } did not look like something we had seen before. Once you read it it's clear, but the people reviewing wondered what others thought of this, and I said I would ask in here. 🙂 The fact that this is an extension function is not part of the problem, I just wrote it that way in here to be more compact.