Open antoine-de opened 5 years ago
navitia_model could be even better if those String ids were also typed.
why? for semantic?
for semantic but mainly it would make some bugs impossible, something like:
collections.stop_points.get(my_stop_point.stop_area_id)
we will get a nice build error saying that we are mixing StopPoint
and StopArea
I think it's a good idea, but i have concern about the code complexity it would imply.
The
Collection
andIdx
are really great to have lots of statically checked stuff.The transit model has a lot of links between the objects, and for the moment all those links are
String
s. I thinknavitia_model
could be even better if thoseString
ids were also typed.For example the
stop_area_id
in theStopPoint
could be aIdentifier<StopArea>
instead of aString
.We could then also remove the
get_idx
/get
method inCollectionWithId<T>
to take an&Identifier<T>
instead of a&str
.We would also need to find a nice name for this identifier. I don't think we can use the obvious
Id
because it's already aTrait
.Identifier
?Link
?TypedId
?TId
? any other thing ? another option would be to rename theId
trait (maybe toHasId
?)What do you think ?