Skip to content

Instantly share code, notes, and snippets.

@AdamMc331
Created August 25, 2020 14:39
Show Gist options
  • Save AdamMc331/f3e39e3a2675cd80b857d02fc2de8a1e to your computer and use it in GitHub Desktop.
Save AdamMc331/f3e39e3a2675cd80b857d02fc2de8a1e to your computer and use it in GitHub Desktop.
Showing the idea of separating UI items with data layer items.
// Easy to do this
@Entity
data class User(
@PrimaryKey(autoGenerate = false)
@field:Json(name = "id")
val id: String = "",
@field:Json(name = "display_name")
val displayName: String? = null
)
// Better to do these
data class User(
val id: String = "",
val displayName: String? = null
)
@Entity
data class PersistableUser(
@PrimaryKey(autoGenerate = false)
val id: String,
val displayName: String? = null
)
data class UserDTO(
@field:Json(name = "id")
val id: String? = null,
@field:Json(name = "display_name")
val displayName: String? = null
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment