as a
Lingua Franca for declarative domain modeling
(*) Domain Model ≈ Data Schema ≈ UML diagram
Data Structure | Read API | Write API |
---|---|---|
Clojure Sequence | first, next, rest | conj |
Clojure Map | get, contains?, keys, vals | assoc, dissoc |
DataScript | Datalog, Entity API, Pull API, raw indexes | (dt/with db write) |
Any given bit of the Domain Model gets used (explicitly or not) in many parts of the system:
=> we'd like to make that DRY / declarative
Declare the domain model in one place, and derive the machinery aspects from there
public class User {
UUID id;
@UserPrivate
String email;
String name;
@RefTyped(cardinality="many")
List<User> follows;
@Derived
int n_followers(){}
@Derived
@RefTyped(cardinality="many")
List<Tweet> tweets(){}
}
public class User {
UUID id;
@UserPrivate
String email;
String name;
@RefTyped(cardinality="many")
List<User> follows;
@Derived
int n_followers(){}
@Derived
@RefTyped(cardinality="many")
List<Tweet> tweets(){}
}
Limitations:
(def domain-model-metadata
{:types
[{:entity-type/name :twitteur/User
:entity-type/attributes
[{:attribute/name :user/email
:attribute.scalar/type :string
:twitteur.security/private? true}
{:attribute/name :user/tweets
:attribute/ref-typed? true
:attribute.ref-typed/type :twitteur/Tweet
:attribute.ref-typed/many? true}
...]}
{:entity-type/name :twitteur/Tweet
:entity-type/attributes
[...]}]})
Limitation: still a poor query API