I have three classes in a project: “StopPoint” contains a list of bus stops together with geocodes; “RouteLink” describes a route between two StopPoint objects referred to by the StopPoint ID at each end of the link; and “Service” which is a public transport service containing a collection of StopPoints and a collection of RouteLinks.
The RouteLink class has a property, LinkDistance, which is read only and is calculated from the geocodes of the two StopPoints.
What I am finding that I have to do is to store the geocodes of the StopPoints as part of the RouteLink in order to calculate the LinkDistance. This is because my class (or collection – not sure which) doesn’t seem to let me define a Parent method to return the Service class, which would allow me to refer back to the StopPoint collection. This leaves me having to store at least some of the the StopPoint information twice, which is unhelpful and inefficient. I’ve scratched my head, but I can’t see a sensible way to get around it. Can anyone help, please.
Thanks.