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

Refactor NearbyStopsFinder to follow strategy pattern #5906

Conversation

habrahamsson-skanetrafiken
Copy link
Contributor

@habrahamsson-skanetrafiken habrahamsson-skanetrafiken commented Jun 13, 2024

Summary

This PR is a pure refactor and shouldn't change any behaviour.

The NearbyStopsFinder has three different behaviours depending on two different parameters:

  • Default street search, used if the graph has a street network.
  • Straight line search, used if the graph doesn't have a street network.
  • A special search considering TripPatterns that is used in conjunction with one of the above. Used if the ConsiderPatternsForDirectTransfers feature is enabled.

The different branches makes the code difficult to understand and difficult to test. This PR refactors this code to use the strategy pattern by extracting a common interface and having one class for each behaviour.

This work is in preparation of some work I need to do on access/egress search as part of #5848.

Unit tests

Unfortunately there is no tests for this piece of code. I would like to add some in a follow-up PR.

Documentation

I added and updated javadoc.

Bumping the serialization version id

Nope

This commit should only change structure. No behaviour should be
affected.
@habrahamsson-skanetrafiken habrahamsson-skanetrafiken requested a review from a team as a code owner June 13, 2024 06:40
Copy link

codecov bot commented Jun 13, 2024

Codecov Report

Attention: Patch coverage is 92.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 69.45%. Comparing base (b9e54d2) to head (960480d).
Report is 25 commits behind head on dev-2.x.

Files Patch % Lines
.../graph_builder/module/DirectTransferGenerator.java 81.81% 1 Missing and 1 partial ⚠️
...earbystops/PatternConsideringNearbyStopFinder.java 92.59% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #5906      +/-   ##
=============================================
- Coverage      69.45%   69.45%   -0.01%     
- Complexity     17064    17072       +8     
=============================================
  Files           1927     1931       +4     
  Lines          73578    73587       +9     
  Branches        7549     7550       +1     
=============================================
+ Hits           51106    51109       +3     
- Misses         19847    19853       +6     
  Partials        2625     2625              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@leonardehrenfried leonardehrenfried left a comment

Choose a reason for hiding this comment

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

This is a good refactoring. I look forward to the tests.

@t2gran t2gran added this to the 2.6 (next release) milestone Jun 19, 2024
Copy link
Member

@t2gran t2gran left a comment

Choose a reason for hiding this comment

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

Just one JavaDoc need to be updated.

@leonardehrenfried leonardehrenfried requested a review from t2gran June 20, 2024 13:17
@leonardehrenfried leonardehrenfried merged commit 2257f88 into opentripplanner:dev-2.x Jun 20, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants