Make all entities identifiable #46

Closed
opened 2026-09-09 06:29:05 +02:00 by c.fahner · 0 comments
Owner

Currently entities have to opt-in to being identifiable (ie. having a unique 'id' field) by implementing the Identifiable interface. This results in code working with entities being littered with instanceof checks for Identifiable even though this is the most common case.

The Schema object already allows classes that are not Entity's, so forcing all entities to have an 'id' field does not make it impossible to make schemas from non-identifiable objects nor does it disallow referencing such objects from other schemas. What would need to change is the way non-entities are referenced by a foreign key, as the Entity interface can't be used as a marker anymore.

Therefor, the Entity\Identifiable interface should be merged with the Entity interface to improve the common case.

Currently entities have to opt-in to being identifiable (ie. having a unique 'id' field) by implementing the `Identifiable` interface. This results in code working with entities being littered with `instanceof` checks for `Identifiable` even though this is the most common case. The `Schema` object already allows classes that are not `Entity`'s, so forcing all entities to have an 'id' field does not make it impossible to make schemas from non-identifiable objects nor does it disallow referencing such objects from other schemas. What would need to change is the way non-entities are referenced by a foreign key, as the `Entity` interface can't be used as a marker anymore. Therefor, the `Entity\Identifiable` interface should be merged with the `Entity` interface to improve the common case.
c.fahner added this to the v0.2 milestone 2026-09-09 06:29:05 +02:00
c.fahner added spent time 2026-09-15 16:43:02 +02:00
30 minutes
c.fahner added spent time 2026-09-17 08:38:32 +02:00
10 minutes
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Total time spent: 40 minutes
c.fahner
40 minutes
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
slendium/ocd#46
No description provided.