This is an attempt to model domain in semantic shapes.
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:
- We get a combinatorial explosion in data classes proliferation
- Every class is not compatible with each other. For example
User
has to inheritUserWithoutAddress
. So that in places where function expectsUserWithoutAddress
we should be able to provideUser
. - To make them compatible we also have to write interfaces for each of them.
- Clojure Schema (see Rich Hickey talk and this article)
- Elixir type system
- Look at Manifold, maybe it makes sense to integrate with them or at least borrow some ideas
- Structural typing in Java