Created
June 12, 2020 12:03
-
-
Save jjl/bdc180a0f3d61826b659b4298b21bc52 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Trait tables | |
An alternative idea I've been playing with recently takes inspiration | |
from game design, where ECS (entity component system) libraries are | |
the norm. | |
Objects normally can be thought of as a set of named fields. In an | |
ECS, an entity is just an id and it can have any number of | |
components. A component is the set of named fields traditionally like | |
an object, except we can have multiple of them. | |
ECS systems allow preserving the benefits of static typing while | |
allowing code to only care about the components it cares about. By | |
carving at the component level, we are able to build on some details | |
without being fully coupled to the implementation details. | |
Pointers allow us to point to records in a number of tables in the | |
database. By using ECS component-style tables (not themselves | |
pointable), code which cares about certain components may join to | |
those tables. Thus even though a pointer may point to conceptually | |
many tables, common components may be queried by code without having | |
to encode the knowledge of what the types are in the query. It's a bit | |
like graphql interfaces ("data interfaces") for the database. | |
When inserting a pointable type, it is up to the user's code to insert | |
the components they care about. When updating one, perhaps the | |
relevant components must be updated. When deleting one, you will have | |
to cascade deletes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment