Skip to content

alexbezhan/kotlin-schema

Repository files navigation

About

This is an attempt to model domain in semantic shapes.

Problem

Let's say we try to model User domain.

User has attributes: id, first, last, address.

Address has attributes: city, zip, state.

If we try to implement the following functions:

  • createUser(first, last, address.city, address.zip, address.state): ExistingUser
  • greet(UserWithName): String
  • userGeo(UserWithIdAndAddressZip)
  • getUserWithoutAddress(): UserWithoutAddress
  • getUser(): User

We quickly realize that:

  1. We get a combinatorial explosion in data classes proliferation
  2. Every class is not compatible with each other. For example User has to inherit UserWithoutAddress. So that in places where function expects UserWithoutAddress we should be able to provide User.
  3. To make them compatible we also have to write interfaces for each of them.

Inspirations:

Ideas to explore:

About

Modeling domain with Kotlin types

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages