Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: NAV-52 - First throw at defining interfaces for a public transport interface. #19

Merged
merged 5 commits into from
May 27, 2024

Conversation

clukas1
Copy link
Member

@clukas1 clukas1 commented May 24, 2024

Proposal for a general interface for the Public Transport Service Interface

@clukas1 clukas1 requested a review from munterfi May 24, 2024 16:26
@clukas1 clukas1 self-assigned this May 24, 2024
Copy link
Member

@munterfi munterfi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, nice work @clukas1! I think this is a well structured interface for our service 👍

I added quite a lot of comments, but they are more about details and conventions:

  • Remove redundancy in names (getRouteId -> getId) member variables (Locations and Stops)
  • Only add fully specified methods (so no overloads with defaults for paramters), since then it is in the control of the implementing class, which I think is not what we want.
  • NotNull, maybe we should set this as default and only use Nullable? Otherwise it gets with verbose.

Something I am not sure yet what a good solution could be is the differentiation between trip / route and walking legs. Somehow I don't like the nullable members.

I will checkout a new branch review/NAV-52 and refactor my suggestions, and add a PR for your review.

import java.time.LocalDate;

public interface ArrivalTime {
@NotNull LocalDate getArrivalTime();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we introduce / use this annotation? It gets quite verbose...

Until now we just marked @nullable fields and assumed that fields without annotations are never null.


import java.time.LocalDate;

public interface ArrivalTime {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? LocalDateTime and the variable name arrival or departure time should be sufficient in my opinion.

import java.time.LocalDate;

public interface DepartureTime {
@NotNull LocalDate getDepartureTime();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I would not wrap a single data type. We can achieve clarity here by using the variable name "departueTime". Or is there a benefit I don't see yet?

public interface Leg {
@NotNull Location getDepartureLocation();

@NotNull Location getArrivalLocation();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not return the location separately... the location can be retrieved via the stop.getLocation()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A leg can be from a random coordinate to the nearest stop. So there are cases where stop will be null


@Nullable Stop getArrivalStop();

@NotNull DepartureTime getDepartureTime();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use normal LocalTime here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was mainly an idea to allow method overrides for getConnections() / earliestArrivals() specifying the direction of travel. But this could of course also be moved to the QueryConfig interface.

@@ -0,0 +1,8 @@
package ch.naviqore.service;

public enum SearchType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool :)

import org.jetbrains.annotations.NotNull;

public interface Stop extends Location {
@NotNull String getStopId();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getId()


@NotNull Stop getStop();

@NotNull ArrivalTime getArrivalTime();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LocalDateTime


@NotNull Route getRoute();

@NotNull StopTime getStartStop();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant, since information can be retrieved via stop times.

import org.jetbrains.annotations.Nullable;

public interface Walk {
@NotNull Location getStart();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant, since can be retrieved via Stop. Except we support walks from random locations to stops. E.g. from an address to the station. But I would keep it simple and extend the interface if we need it.

- Rename to project consistent names: Nearest, connection, source and target.
- Remove methods that allow default parameters in the implementation.
- Remove redundant information in the interface which can be retrieved from member objects further down.
@munterfi
Copy link
Member

Please see #21

munterfi and others added 2 commits May 27, 2024 19:12
…for-service

REFACTOR: NAV-52 - Remove redundancy in public transit service interface
@clukas1 clukas1 requested a review from munterfi May 27, 2024 17:31
@munterfi munterfi merged commit a28c7fd into main May 27, 2024
1 check passed
@munterfi munterfi deleted the feature/NAV-52-define-interfaces-for-service branch May 27, 2024 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants