I am putting a base for Android (Kotlin) and iOS app (Swift). I am in a dilemma regarding Model classes.
Say for example I have the following APIs
/cars
GET /car/{id}
POST /car
All the APIs use Car Object. But the /cars list API returns limited properties whereas GET /car/{id} returns all the properties.
Same way the Car Model I use in add/edit Car view is this same Car Object with few properties unused.
So instead of maintaining separate Car model for all these APIs I am planning to create only one with all properties as optional.
Car {
var id: String?
var name: String?
var type: String?
var speed: String?
var avg: String?
var model: String?
...
}
The extra overhead is, I have use to force unwrap carefully based on which API I am using. Is this design pattern fine for production app.
Any production examples from Github will also be helpful.
2