Skip to content

Documentation how to name things #109

@StefMa

Description

@StefMa

Internally we have this doc 👇

Details

Naming

All of our models which are required to communicate to our backend are prefixed with Api.

Examples: ApiProduct, ApiRideResponse, ApiFare, ...

Properties, which are part of one "top-level" API-Model and not shared in other API-Models has to be a sub-class of those "top-level" API-Model and does not require the Api prefix.

Default values

Since we are not in control of those models, because they are defined by our backend, we decided that we stick as much as possible to the JSON objects. That means we do not add default values to those models.

Testing

Sometimes it is hard to create such an API-Model because it requires a lot of properties.
In tests, we use for that "fake helpers".
Those helpers are functions with properties and default values.
The return value will be an instance of the API-Model.

Example:

fun createProvider(
  features: ApiProvider.Features = createFeatures(),
  fare: ApiFare? = null
) = ApiProvider(
  features = features,
  fare = fare
)

Full example

data class ApiProvider(
  val features: Features,
  val fare: ApiFare?
) {
  data class Features(
    val flag: Boolean
  )
}

data class ApiFare(...)

data class ApiSomethingElse(val fare: ApiFare)

I guess we should also commit/document this here somwhere...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions