tree-ware / tree-ware-kotlin-core

Apache License 2.0
1 stars 0 forks source link

Self-host the schema #24

Closed deepak-nulu closed 3 years ago

deepak-nulu commented 3 years ago

The schema for a tree-ware model is currently defined using Kotlin classes. But tree-ware should be able to model any data, including a schema. So tree-ware should be able to self-host the schema as a model.

The advantage of self-hosting the schema is that all the functionality available for models now become available for the schema as well. The most useful shared functionality would be the ability to compute the difference between two versions of the schema.

The disadvantage of self-hosting the schema is the loss of type-safety. But this only impacts developers of tree-ware, not users of tree-ware. We are fine with type unsafe code inside tree-ware as long as it does not impact users. Type-unsafe code inside tree-ware will be covered fully by unit-tests. A schema for the schema will be available to ensure that users have proper build-time validation, more validation than what the type-system alone can provide.

The schema classes will have to co-exist with the self-hosted-schema during the transition. To prevent naming collisions during the transition, the self-hosted-schema will be called meta-model, and the schema for the meta-model will be called meta-meta-model. These new names will remain even after the transition.

Due to the circular nature of self-hosting, multiple steps are required to complete the transition.