Created
August 25, 2020 14:39
-
-
Save AdamMc331/f3e39e3a2675cd80b857d02fc2de8a1e to your computer and use it in GitHub Desktop.
Showing the idea of separating UI items with data layer items.
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
// 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