Gustav Elmgren
12/08/2022, 5:02 PMdata class StudentDTO(val id: Long, val name: String)
data class Student(val id: Long, val name: String)
This would probably work easier in java (for good and bad reasons), given that the ID could be null, given we use StudentDTO
as the RequestBody
in a POST
request. I don't like the approach with nullable id in the DTO. So I guess you would have to create multiple models for different scenarios?
data class CreateStudentDTO(val name: String) --> Used when parsing the request
data class ReturnStudentDTO(val id: Long, name: String) --> Used to return from the controller
data class CreateStudent(val name: String) -> Used as an argument in the service layer
data class Student(val id: Long, name: String) -> Used as a return in the service layer
Andrew O'Hara
12/08/2022, 5:12 PMGustav Elmgren
12/08/2022, 6:10 PMAndrew O'Hara
12/08/2022, 6:13 PMJpaCat
, DynamoCat
, etc. Exception for exposed, which has ExposedCatTable
, and potentially ExposedCatEntity
.
Business Models: plain, or suffixed with variant, eg. Cat
, CatUpdateData
, etc
DTOs: Suffix the business model name with the DTO version: e.g. CatDtoV1
, CatDtoV2
, CatUpdateDataV2
, etc.Jared Schlicht
12/08/2022, 6:21 PMJared Schlicht
12/08/2022, 6:21 PMGustav Elmgren
12/08/2022, 7:23 PMcat
package with all the different variations, or do you have a DTO
package with all different DTOs (dogs, cats). As well as a Exposed
package, and so on...Andrew O'Hara
12/08/2022, 7:31 PMGustav Elmgren
12/08/2022, 7:32 PMpsh
12/08/2022, 7:47 PMGustav Elmgren
12/08/2022, 7:49 PMkqr
12/13/2022, 9:01 AMAndrew O'Hara
12/13/2022, 1:13 PM